core

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CgoAvailable added in v1.22.23

func CgoAvailable() bool

CgoAvailable returns true when CGO is enabled (but ZMQ is not required)

Types

type Block

type Block interface {
	ID() ids.ID
	ParentID() ids.ID
	Height() uint64
	Timestamp() int64
	Bytes() []byte
	Verify(context.Context) error
	Accept(context.Context) error
	Reject(context.Context) error
}

Block interface for consensus

type BlockStatus

type BlockStatus uint8

BlockStatus represents block status

const (
	StatusUnknown BlockStatus = iota
	StatusProcessing
	StatusAccepted
	StatusRejected
)

type CGOConsensus

type CGOConsensus struct {
	// contains filtered or unexported fields
}

CGOConsensus is a CGO-based implementation of consensus For now, it's the same as the pure Go implementation

func NewCGOConsensus

func NewCGOConsensus(params ConsensusParams) (*CGOConsensus, error)

NewCGOConsensus creates a new CGO consensus engine

func (*CGOConsensus) Add

func (c *CGOConsensus) Add(block Block) error

Add adds a block to consensus

func (*CGOConsensus) Finalized

func (c *CGOConsensus) Finalized() bool

Finalized checks if consensus is finalized

func (*CGOConsensus) GetPreference

func (c *CGOConsensus) GetPreference() ids.ID

GetPreference returns the current preference

func (*CGOConsensus) HealthCheck

func (c *CGOConsensus) HealthCheck() error

HealthCheck performs a health check

func (*CGOConsensus) IsAccepted

func (c *CGOConsensus) IsAccepted(blockID ids.ID) bool

IsAccepted checks if a block is accepted

func (*CGOConsensus) Parameters

func (c *CGOConsensus) Parameters() ConsensusParams

Parameters returns consensus parameters

func (*CGOConsensus) RecordPoll

func (c *CGOConsensus) RecordPoll(blockID ids.ID, accept bool) error

RecordPoll records a poll result

type Consensus

type Consensus interface {
	Add(Block) error
	RecordPoll(ids.ID, bool) error
	IsAccepted(ids.ID) bool
	GetPreference() ids.ID
	Finalized() bool
	Parameters() ConsensusParams
	HealthCheck() error
}

Consensus interface

type ConsensusFactory

type ConsensusFactory struct{}

ConsensusFactory creates the appropriate consensus implementation This is the CGO version when CGO is enabled

func NewConsensusFactory

func NewConsensusFactory() *ConsensusFactory

NewConsensusFactory creates a new consensus factory

func (*ConsensusFactory) CreateConsensus

func (f *ConsensusFactory) CreateConsensus(params ConsensusParams) (Consensus, error)

CreateConsensus creates a consensus engine instance

type ConsensusParams

type ConsensusParams struct {
	K                     int
	AlphaPreference       int
	AlphaConfidence       int
	Beta                  int
	ConcurrentPolls       int
	OptimalProcessing     int
	MaxOutstandingItems   int
	MaxItemProcessingTime time.Duration
}

ConsensusParams defines consensus parameters

type Fx

type Fx struct {
	ID ids.ID
	Fx interface{}
}

Fx represents a feature extension

type Message added in v1.22.18

type Message struct {
	Type    MessageType
	NodeID  ids.NodeID
	Content []byte
}

Message represents a VM-to-engine message

type MessageType

type MessageType uint32

MessageType defines the type of a message

const (
	// PendingTxs indicates pending transactions
	PendingTxs MessageType = iota
	// PutBlock indicates a block to be added
	PutBlock
	// GetBlock indicates a request for a block
	GetBlock
	// GetAccepted indicates a request for accepted blocks
	GetAccepted
	// Accepted indicates an accepted block
	Accepted
	// GetAncestors indicates a request for ancestors
	GetAncestors
	// MultiPut indicates multiple blocks
	MultiPut
	// GetFailed indicates a failed get request
	GetFailed
	// QueryFailed indicates a failed query
	QueryFailed
	// Chits indicates chits message
	Chits
	// ChitsV2 indicates chits v2 message
	ChitsV2
	// GetAcceptedFrontier indicates a request for accepted frontier
	GetAcceptedFrontier
	// AcceptedFrontier indicates accepted frontier
	AcceptedFrontier
	// GetAcceptedFrontierFailed indicates a failed frontier request
	GetAcceptedFrontierFailed
	// WarpRequest indicates a warp request
	WarpRequest
	// WarpResponse indicates a warp response
	WarpResponse
	// WarpGossip indicates warp gossip
	WarpGossip
	// StateSyncDone indicates state sync has completed
	StateSyncDone
)

func (MessageType) String added in v1.22.18

func (m MessageType) String() string

String returns the string representation of the message type

type Stats

type Stats struct {
	BlocksAccepted        uint64
	BlocksRejected        uint64
	VotesProcessed        uint64
	PollsCompleted        uint64
	AverageDecisionTimeMs float64
}

Stats represents consensus statistics

Directories

Path Synopsis
Package coremock provides mock implementations for core consensus
Package coremock provides mock implementations for core consensus
Package coretest provides test utilities for consensus engine core
Package coretest provides test utilities for consensus engine core

Jump to

Keyboard shortcuts

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