github.com/MetalBlockchain/metalgo@v1.11.9/vms/platformvm/txs/advance_time_tx.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package txs 5 6 import ( 7 "time" 8 9 "github.com/MetalBlockchain/metalgo/ids" 10 "github.com/MetalBlockchain/metalgo/snow" 11 "github.com/MetalBlockchain/metalgo/utils/set" 12 "github.com/MetalBlockchain/metalgo/vms/components/avax" 13 ) 14 15 var _ UnsignedTx = (*AdvanceTimeTx)(nil) 16 17 // AdvanceTimeTx is a transaction to increase the chain's timestamp. 18 // When the chain's timestamp is updated (a AdvanceTimeTx is accepted and 19 // followed by a commit block) the staker set is also updated accordingly. 20 // It must be that: 21 // - proposed timestamp > [current chain time] 22 // - proposed timestamp <= [time for next staker set change] 23 type AdvanceTimeTx struct { 24 // Unix time this block proposes increasing the timestamp to 25 Time uint64 `serialize:"true" json:"time"` 26 27 unsignedBytes []byte // Unsigned byte representation of this data 28 } 29 30 func (tx *AdvanceTimeTx) SetBytes(unsignedBytes []byte) { 31 tx.unsignedBytes = unsignedBytes 32 } 33 34 func (tx *AdvanceTimeTx) Bytes() []byte { 35 return tx.unsignedBytes 36 } 37 38 func (*AdvanceTimeTx) InitCtx(*snow.Context) {} 39 40 // Timestamp returns the time this block is proposing the chain should be set to 41 func (tx *AdvanceTimeTx) Timestamp() time.Time { 42 return time.Unix(int64(tx.Time), 0) 43 } 44 45 func (*AdvanceTimeTx) InputIDs() set.Set[ids.ID] { 46 return nil 47 } 48 49 func (*AdvanceTimeTx) Outputs() []*avax.TransferableOutput { 50 return nil 51 } 52 53 func (*AdvanceTimeTx) SyntacticVerify(*snow.Context) error { 54 return nil 55 } 56 57 func (tx *AdvanceTimeTx) Visit(visitor Visitor) error { 58 return visitor.AdvanceTimeTx(tx) 59 }