context

package
v1.19.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2025 License: BSD-3-Clause Imports: 3 Imported by: 22

Documentation

Overview

Package context provides consensus context for VMs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetChainID

func GetChainID(ctx context.Context) ids.ID

GetChainID gets the chain ID from context

func GetNetID

func GetNetID(ctx context.Context) ids.ID

GetNetID gets the network ID from context

func GetNetworkID

func GetNetworkID(ctx context.Context) uint32

GetNetworkID gets the network ID from context

func GetNodeID

func GetNodeID(ctx context.Context) ids.NodeID

GetNodeID gets the node ID from context

func GetSubnetID deprecated

func GetSubnetID(ctx context.Context) ids.ID

Deprecated: GetSubnetID is deprecated, use GetNetID instead

func GetTimestamp

func GetTimestamp() int64

GetTimestamp returns the current timestamp

func WithContext

func WithContext(ctx context.Context, cc *Context) context.Context

WithContext adds consensus context to a context

func WithIDs

func WithIDs(ctx context.Context, ids IDs) context.Context

WithIDs adds IDs to the context

func WithValidatorState

func WithValidatorState(ctx context.Context, vs ValidatorState) context.Context

WithValidatorState adds validator state to the context

Types

type BlockchainIDLookup

type BlockchainIDLookup interface {
	Lookup(alias string) (ids.ID, error)
}

BlockchainIDLookup provides blockchain ID lookup

type Context

type Context struct {
	// QuantumID is the root quantum network identifier
	QuantumID uint32 `json:"quantumID"`
	// NetworkID is an alias for QuantumID for backward compatibility
	NetworkID uint32 `json:"networkID"`
	// NetID identifies the specific network/subnet within the quantum network
	NetID ids.ID `json:"netID"`
	// ChainID identifies the specific chain within the network
	ChainID     ids.ID     `json:"chainID"`
	NodeID      ids.NodeID `json:"nodeID"`
	PublicKey   []byte     `json:"publicKey"`
	XChainID    ids.ID     `json:"xChainID"`
	CChainID    ids.ID     `json:"cChainID"`
	AVAXAssetID ids.ID     `json:"avaxAssetID"`
	LUXAssetID  ids.ID     `json:"luxAssetID"`
	// XAssetID is an alias for LUXAssetID for backward compatibility
	XAssetID ids.ID `json:"xAssetID"`

	// Timing
	StartTime time.Time `json:"startTime"`

	// Additional fields for consensus
	ValidatorState ValidatorState
	Keystore       Keystore
	BCLookup       BlockchainIDLookup
	Metrics        Metrics
}

Context provides consensus context for VMs

func FromContext

func FromContext(ctx context.Context) *Context

FromContext extracts consensus context from a context

type GetValidatorOutput

type GetValidatorOutput struct {
	NodeID    ids.NodeID
	PublicKey []byte
	Weight    uint64
}

GetValidatorOutput contains validator information

type IDs

type IDs struct {
	// NetworkID is the network identifier
	NetworkID uint32
	// QuantumID is the root quantum network identifier
	QuantumID uint32
	// NetID identifies the network within the quantum network
	NetID ids.ID
	// ChainID identifies the chain within the network
	ChainID   ids.ID
	NodeID    ids.NodeID
	PublicKey []byte
	// LUXAssetID is the asset ID for LUX
	LUXAssetID ids.ID
}

IDs holds the IDs for consensus context

type Keystore

type Keystore interface {
	GetDatabase(username, password string) (interface{}, error)
	NewAccount(username, password string) error
}

Keystore provides key management

type Metrics

type Metrics interface {
	Register(namespace string, registerer interface{}) error
}

Metrics provides metrics tracking

type ValidatorState

type ValidatorState interface {
	GetChainID(ids.ID) (ids.ID, error)
	GetNetID(ids.ID) (ids.ID, error)
	GetSubnetID(chainID ids.ID) (ids.ID, error)
	GetValidatorSet(uint64, ids.ID) (map[ids.NodeID]uint64, error)
	GetCurrentHeight() (uint64, error)
	GetMinimumHeight(context.Context) (uint64, error)
}

ValidatorState provides validator information

func GetValidatorState

func GetValidatorState(ctx context.Context) ValidatorState

GetValidatorState gets the validator state from context

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL