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