block

package
v1.22.25 Latest Latest
Warning

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

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

Documentation

Overview

Package block provides block interfaces for consensus

Index

Constants

This section is empty.

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 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<- Message,
		fxs []*Fx,
		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 Fx

type Fx struct {
	ID   ids.ID
	Name string
}

Fx represents a feature extension

type Message

type Message interface {
	// Get returns the message bytes
	Get() []byte
}

Message represents a consensus message

type Status

type Status uint8

Status represents the status of a block

const (
	// Unknown status
	Unknown Status = iota
	// Processing status
	Processing
	// Rejected status
	Rejected
	// Accepted status
	Accepted
	// Verified status
	Verified
)

Jump to

Keyboard shortcuts

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