Documentation
¶
Overview ¶
Package block provides block interfaces for consensus
Index ¶
Constants ¶
View Source
const ( Unknown = choices.Unknown Processing = choices.Processing Rejected = choices.Rejected Accepted = choices.Accepted )
Status constants re-exported from choices
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block interface {
ID() ids.ID
Height() uint64
Timestamp() int64
Parent() ids.ID
Bytes() []byte
Status() Status
Accept(context.Context) error
Reject(context.Context) error
Verify(context.Context) error
}
Block is a block in the chain
type BlockMessage ¶ added in v1.22.26
type BlockMessage interface {
// Get returns the message bytes
Get() []byte
}
BlockMessage represents a block-specific consensus message
type ChainContext ¶
type ChainContext struct {
// 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
// Additional fields
XChainID ids.ID
CChainID ids.ID
XAssetID ids.ID
// Consensus context
Ctx *consensuscontext.Context
}
ChainContext provides context for chain operations
type ChainVM ¶
type ChainVM interface {
// Initialize the VM
Initialize(
ctx context.Context,
chainCtx *ChainContext,
dbManager database.Database,
genesisBytes []byte,
upgradeBytes []byte,
configBytes []byte,
toEngine chan<- BlockMessage,
fxs []*BlockFx,
sender warp.Sender,
) error
// BuildBlock builds a new block
BuildBlock(context.Context) (Block, error)
// ParseBlock parses a block from bytes
ParseBlock(context.Context, []byte) (Block, error)
// GetBlock gets a block by ID
GetBlock(context.Context, ids.ID) (Block, error)
// SetPreference sets the preferred block
SetPreference(context.Context, ids.ID) error
// LastAccepted returns the last accepted block
LastAccepted(context.Context) (ids.ID, error)
// GetBlockIDAtHeight returns block ID at height
GetBlockIDAtHeight(context.Context, uint64) (ids.ID, error)
// Shutdown shuts down the VM
Shutdown(context.Context) error
// CreateHandlers creates HTTP handlers
CreateHandlers(context.Context) (map[string]http.Handler, error)
// CreateStaticHandlers creates static HTTP handlers
CreateStaticHandlers(context.Context) (map[string]http.Handler, error)
// HealthCheck performs a health check
HealthCheck(context.Context) (interface{}, error)
// Version returns the version
Version(context.Context) (string, error)
// Connected is called when a node connects
Connected(context.Context, ids.NodeID, *version.Application) error
// Disconnected is called when a node disconnects
Disconnected(context.Context, ids.NodeID) error
}
ChainVM defines the interface for a blockchain VM
Click to show internal directories.
Click to hide internal directories.