block

package
v1.22.45 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

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 BlockFx added in v1.22.26

type BlockFx struct {
	ID   ids.ID
	Name string
}

BlockFx represents a block-specific feature extension

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

type Status

type Status = choices.Status

Status re-exports from choices for consistency

Jump to

Keyboard shortcuts

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