mirror of
https://github.com/luxfi/proto.git
synced 2026-10-30 15:21:09 +00:00
- Rename InitCtx → InitRuntime throughout - Update imports for new package versions - Update utxo/secp256k1fx usage - Update consensus context references
68 lines
1.7 KiB
Go
68 lines
1.7 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package txs
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/luxfi/runtime"
|
|
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/math/set"
|
|
lux "github.com/luxfi/utxo"
|
|
)
|
|
|
|
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) InitRuntime(*runtime.Runtime) {}
|
|
|
|
// 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() []*lux.TransferableOutput {
|
|
return nil
|
|
}
|
|
|
|
func (*AdvanceTimeTx) SyntacticVerify(*runtime.Runtime) error {
|
|
return nil
|
|
}
|
|
|
|
func (tx *AdvanceTimeTx) Visit(visitor Visitor) error {
|
|
return visitor.AdvanceTimeTx(tx)
|
|
}
|
|
|
|
// InitializeWithContext initializes the transaction with consensus context
|
|
func (tx *AdvanceTimeTx) InitializeWithContext(ctx context.Context) error {
|
|
// Initialize any context-dependent fields here
|
|
return nil
|
|
}
|