Documentation
¶
Overview ¶
Package context provides consensus context for VMs
Index ¶
- func GetChainID(ctx context.Context) ids.ID
- func GetNetID(ctx context.Context) ids.ID
- func GetNetworkID(ctx context.Context) uint32
- func GetNodeID(ctx context.Context) ids.NodeID
- func GetSubnetID(ctx context.Context) ids.IDdeprecated
- func GetTimestamp() int64
- func GetWarpSigner(ctx context.Context) interface{}
- func WithContext(ctx context.Context, cc *Context) context.Context
- func WithIDs(ctx context.Context, ids IDs) context.Context
- func WithValidatorState(ctx context.Context, vs ValidatorState) context.Context
- type BCLookup
- type BlockchainIDLookup
- type Context
- type GetValidatorOutput
- type IDs
- type Keystore
- type Logger
- type Metrics
- type NetworkUpgrades
- type SharedMemory
- type ValidatorState
- type WarpSigner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetChainID ¶
GetChainID gets the chain ID from context
func GetNetworkID ¶
GetNetworkID gets the network ID from context
func GetSubnetID
deprecated
func GetWarpSigner ¶ added in v1.22.2
GetWarpSigner gets the warp signer from context
func WithContext ¶
WithContext adds consensus context to a context
func WithValidatorState ¶
func WithValidatorState(ctx context.Context, vs ValidatorState) context.Context
WithValidatorState adds validator state to the context
Types ¶
type BCLookup ¶ added in v1.22.23
type BCLookup interface {
Lookup(alias string) (ids.ID, error)
PrimaryAlias(id ids.ID) (string, error)
Aliases(id ids.ID) ([]string, error)
}
BCLookup provides blockchain alias lookup
type BlockchainIDLookup ¶
type BlockchainIDLookup = BCLookup
BlockchainIDLookup is an alias for BCLookup for backward compatibility
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"`
SubnetID ids.ID `json:"subnetID"` // Alias for 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"`
XAssetID ids.ID `json:"xAssetID"`
LUXAssetID ids.ID `json:"luxAssetID"`
ChainDataDir string `json:"chainDataDir"`
// Timing
StartTime time.Time `json:"startTime"`
ValidatorState interface{}
Keystore Keystore
Metrics interface{}
Log interface{} // logging.Logger
BCLookup BCLookup // Blockchain alias lookup
WarpSigner interface{} // warp.Signer
NetworkUpgrades interface{} // upgrade.Config
// Lock for thread-safe access to context
Lock sync.RWMutex
}
Context provides consensus context for VMs
func FromContext ¶
FromContext extracts consensus context from a context
type GetValidatorOutput ¶
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
// XAssetID is the asset ID for the X-Chain native asset
XAssetID ids.ID
LUXAssetID ids.ID `json:"luxAssetID"`
ChainDataDir string `json:"chainDataDir"`
}
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 Logger ¶ added in v1.19.12
type Logger interface {
Debug(msg string, fields ...interface{}) // zap.Field
Info(msg string, fields ...interface{}) // zap.Field
Warn(msg string, fields ...interface{}) // zap.Field
Error(msg string, fields ...interface{}) // zap.Field
Fatal(msg string, fields ...interface{}) // zap.Field
}
Logger provides logging functionality
type NetworkUpgrades ¶ added in v1.19.12
type NetworkUpgrades interface {
}
NetworkUpgrades contains network upgrade activation times
type SharedMemory ¶ added in v1.19.12
type SharedMemory interface {
peerChainID ids.ID,
traits [][]byte,
startTrait, startKey []byte,
limit int,
) (values [][]byte, lastTrait, lastKey []byte, err error)
}
SharedMemory provides cross-chain shared memory
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(context.Context) (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
type WarpSigner ¶ added in v1.19.12
WarpSigner provides BLS signing for Warp messages