consensus

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: GPL-3.0, LGPL-3.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownAncestor is returned when validating a block requires an ancestor
	// that is unknown.
	ErrUnknownAncestor = errors.New("unknown ancestor")

	// ErrPrunedAncestor is returned when validating a block requires an ancestor
	// that is known, but the state of which is not available.
	ErrPrunedAncestor = errors.New("pruned ancestor")

	// ErrFutureBlock is returned when a block's timestamp is in the future according
	// to the current node.
	ErrFutureBlock = errors.New("block in the future")

	// ErrInvalidNumber is returned if a block's number doesn't equal its parent's
	// plus one.
	ErrInvalidNumber = errors.New("invalid block number")
)

Functions

This section is empty.

Types

type AliasManager added in v0.8.0

type AliasManager interface {
	Alias(ids.ID, string) error
	Aliases(ids.ID) ([]string, error)
	PrimaryAlias(ids.ID) (string, error)
}

AliasManager interface

type Block added in v0.8.0

type Block interface {
	ID() ids.ID
	ParentID() ids.ID
	Height() uint64
	Verify() error
	Accept() error
	Reject() error
	Status() Status
}

Block is the interface for linear blocks

type ChainHeaderReader

type ChainHeaderReader = iface.ChainHeaderReader

Use interfaces from the iface package

type ChainReader

type ChainReader = iface.ChainReader

type Consensus added in v0.8.0

type Consensus interface {
	Add(Block) error
	Finalized() bool
}

Consensus interface for linear consensus

type Context added in v0.8.0

type Context struct {
	NetworkID    uint32
	SubnetID     ids.ID
	ChainID      ids.ID
	NodeID       ids.NodeID
	PublicKey    *bls.PublicKey
	XChainID     ids.ID
	CChainID     ids.ID
	LUXAssetID   ids.ID
	Log          logging.Logger
	Metrics      metrics.MultiGatherer
	ChainDataDir string
	AliasManager AliasManager
	Validators   ValidatorManager
}

Context is the context for the chain

type Engine

type Engine = iface.Engine

type FeeConfig added in v0.8.0

type FeeConfig interface {
	GetBaseFee(timestamp uint64) *big.Int
	GetMaxGasLimit() *big.Int
}

FeeConfig defines the interface for chain fee configuration

type PoS added in v0.8.0

type PoS interface {
	Engine
}

PoS is a consensus engine based on proof-of-stake (delegated to Lux).

type PoW added in v0.8.0

type PoW interface {
	Engine

	// Hashrate returns the current mining hashrate of a PoW consensus engine.
	Hashrate() float64
}

PoW is a consensus engine based on proof-of-work (deprecated).

type Status added in v0.8.0

type Status uint8

Status represents the status of a block

const (
	Unknown Status = iota
	Processing
	Rejected
	Accepted
)

type Validator added in v0.8.0

type Validator struct {
	NodeID ids.NodeID
	Weight uint64
}

Validator represents a validator

type ValidatorManager added in v0.8.0

type ValidatorManager interface {
	GetValidator(ids.NodeID) (*Validator, bool)
	GetValidatorSet() map[ids.NodeID]*Validator
}

ValidatorManager interface

Directories

Path Synopsis
misc
Package validators is a generated GoMock package.
Package validators is a generated GoMock package.

Jump to

Keyboard shortcuts

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