chain

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotOracle is returned when the block is not an oracle block
	ErrNotOracle = errors.New("block is not an oracle block")
)

Functions

This section is empty.

Types

type Block

type Block interface {
	choices.Decidable

	// Parent returns the parent block ID.
	Parent() ids.ID

	// Height returns the height of the block.
	Height() uint64

	// Time returns the time the block was created.
	Time() uint64

	// Verify that the block is valid.
	Verify(context.Context) error

	// Bytes returns the byte representation of the block.
	Bytes() []byte
}

Block is a block that can be decided.

type Consensus

type Consensus interface {
	// Initialize the consensus with the given parameters.
	Initialize(ctx context.Context, params Parameters) error

	// Parameters returns the parameters of this consensus instance.
	Parameters() Parameters

	// Add a block to consensus consideration.
	Add(ctx context.Context, block Block) error

	// Issued returns true if the block has been issued into consensus.
	Issued(blk Block) bool

	// Processing returns true if the block is currently processing.
	Processing(blkID ids.ID) bool

	// Decided returns true if the block has been decided.
	Decided(blk Block) bool

	// IsPreferred returns true if the block is on the preferred chain.
	IsPreferred(blk Block) bool

	// Preference returns the current preferred block.
	Preference() ids.ID

	// RecordPoll records the results of a network poll.
	RecordPoll(ctx context.Context, votes []ids.ID) error

	// Finalized returns true if consensus has finalized.
	Finalized() bool

	// HealthCheck returns the health status of consensus.
	HealthCheck(ctx context.Context) (interface{}, error)

	// NumProcessing returns the number of currently processing blocks.
	NumProcessing() int
}

Consensus represents a linear consensus instance.

type Engine

type Engine interface {
	core.Engine

	// Initialize this engine.
	Initialize(ctx context.Context, params Parameters) error

	// GetBlock retrieves a block by its ID.
	GetBlock(blkID ids.ID) (Block, error)

	// GetAncestor retrieves an ancestor block at the given height.
	GetAncestor(blkID ids.ID, height uint64) (ids.ID, error)

	// LastAccepted returns the ID of the last accepted block.
	LastAccepted() (ids.ID, uint64)

	// VerifyHeightIndex returns whether height index is enabled.
	VerifyHeightIndex() error
}

Engine is a linear consensus engine.

type Parameters

type Parameters struct {
	// BatchSize is the number of blocks to batch together.
	BatchSize int

	// The consensus parameters.
	ConsensusParams interface{}
}

Parameters defines the parameters for the linear consensus engine.

type VM

type VM interface {
	// GetBlock retrieves a block by its ID.
	GetBlock(ctx context.Context, blkID ids.ID) (Block, error)

	// GetAncestor retrieves an ancestor block at the given height.
	GetAncestor(ctx context.Context, blkID ids.ID, height uint64) (ids.ID, error)

	// LastAccepted returns the ID of the last accepted block.
	LastAccepted(ctx context.Context) (ids.ID, error)

	// ParseBlock parses a block from bytes.
	ParseBlock(ctx context.Context, b []byte) (Block, error)

	// BuildBlock builds a new block.
	BuildBlock(ctx context.Context) (Block, error)

	// SetPreference sets the preferred block.
	SetPreference(ctx context.Context, blkID ids.ID) error

	// VerifyHeightIndex returns whether height index is enabled.
	VerifyHeightIndex(ctx context.Context) error
}

VM defines the interface that the consensus engine uses to interact with the VM.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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