engine

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

Documentation

Overview

Package engine houses the three consensus engines: chain, dag, and pq.

Each engine orchestrates a specific transaction topology: - chain: Linear consensus for sequential blocks - dag: DAG-based consensus for parallel, causally-ordered vertices - pq: Post-quantum hardened consensus with quantum-safe certificates

All engines share the same algorithmic pipeline but differ in their data structures and finality mechanisms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfig added in v1.22.0

func DefaultConfig() types.Config

DefaultConfig returns the default chain configuration

Types

type Chain added in v1.22.0

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

Chain represents a linear blockchain consensus engine

func NewChain added in v1.22.0

func NewChain(config types.Config) *Chain

NewChain creates a new chain consensus engine

func (*Chain) Add added in v1.22.0

func (c *Chain) Add(ctx context.Context, block *types.Block) error

Add adds a new block to the chain

func (*Chain) GetStatus added in v1.22.0

func (c *Chain) GetStatus(id types.ID) types.Status

GetStatus returns the status of a block

func (*Chain) IsAccepted added in v1.22.0

func (c *Chain) IsAccepted(id types.ID) bool

IsAccepted returns whether a block has been accepted

func (*Chain) RecordVote added in v1.22.0

func (c *Chain) RecordVote(ctx context.Context, vote *types.Vote) error

RecordVote records a vote for a block

func (*Chain) Start added in v1.22.0

func (c *Chain) Start(ctx context.Context) error

Start starts the consensus engine

func (*Chain) Stop added in v1.22.0

func (c *Chain) Stop() error

Stop stops the consensus engine

type Engine added in v1.22.0

type Engine interface {
	// Add a new block to the consensus
	Add(ctx context.Context, block *types.Block) error

	// RecordVote records a vote for a block
	RecordVote(ctx context.Context, vote *types.Vote) error

	// IsAccepted returns whether a block has been accepted
	IsAccepted(id types.ID) bool

	// GetStatus returns the status of a block
	GetStatus(id types.ID) types.Status

	// Start the consensus engine
	Start(ctx context.Context) error

	// Stop the consensus engine
	Stop() error
}

Engine is the main consensus engine interface

type LuxConsensus

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

LuxConsensus implements Lux's consensus protocol using Photon → Wave → Focus → Prism → Quasar

func NewLuxConsensus

func NewLuxConsensus(k int, alpha int, beta int) *LuxConsensus

NewLuxConsensus creates a new Lux consensus instance

func (*LuxConsensus) Decided

func (lc *LuxConsensus) Decided() bool

Decided returns whether consensus has been reached

func (*LuxConsensus) Decision

func (lc *LuxConsensus) Decision(item ids.ID) (types.Decision, bool)

Decision returns the decision for an item

func (*LuxConsensus) Parameters

func (lc *LuxConsensus) Parameters() config.Parameters

Parameters returns the consensus parameters

func (*LuxConsensus) Poll

func (lc *LuxConsensus) Poll(responses map[ids.ID]int) bool

Poll conducts a consensus poll using Lux protocols

func (*LuxConsensus) Preference

func (lc *LuxConsensus) Preference() ids.ID

Preference returns the current preferred item

func (*LuxConsensus) RecordVote

func (lc *LuxConsensus) RecordVote(item ids.ID)

RecordVote records a vote for an item

type SimpleCut

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

SimpleCut implements a basic Cut for sampling

func (*SimpleCut) Luminance

func (c *SimpleCut) Luminance() prism.Luminance

Luminance implements Cut interface

func (*SimpleCut) Sample

func (c *SimpleCut) Sample(k int) []types.NodeID

type SimpleTransport

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

SimpleTransport implements basic transport for voting

func (*SimpleTransport) MakeLocalPhoton

func (t *SimpleTransport) MakeLocalPhoton(item ids.ID, prefer bool) wave.Photon[ids.ID]

func (*SimpleTransport) RequestVotes

func (t *SimpleTransport) RequestVotes(ctx context.Context, peers []types.NodeID, item ids.ID) <-chan wave.Photon[ids.ID]

Directories

Path Synopsis
Package bft provides a thin wrapper around github.com/luxfi/bft (Simplex BFT) for integration with the Lux consensus engine interface.
Package bft provides a thin wrapper around github.com/luxfi/bft (Simplex BFT) for integration with the Lux consensus engine interface.
Package chain implements linear consensus protocol.
Package chain implements linear consensus protocol.
block/blockmock
Package blockmock is a generated GoMock package.
Package blockmock is a generated GoMock package.
block/blocktest
Package blocktest provides test utilities for blocks
Package blocktest provides test utilities for blocks
chainmock
Package chainmock provides mock implementations for testing
Package chainmock provides mock implementations for testing
chaintest
Package chaintest provides test utilities for chains
Package chaintest provides test utilities for chains
syncer
Package syncer provides state synchronization for blockchain engines
Package syncer provides state synchronization for blockchain engines
coremock
Package coremock provides mock implementations for core consensus
Package coremock provides mock implementations for core consensus
coretest
Package coretest provides test utilities for consensus engine core
Package coretest provides test utilities for consensus engine core
dag
Package dag provides DAG consensus functionality
Package dag provides DAG consensus functionality
vertex/vertexmock
Package vertexmock provides mock implementations for DAG vertices
Package vertexmock provides mock implementations for DAG vertices
Package enginetest provides test utilities for consensus engines
Package enginetest provides test utilities for consensus engines
pq
Package pq implements the post-quantum consensus engine that combines classical and quantum-resistant consensus mechanisms.
Package pq implements the post-quantum consensus engine that combines classical and quantum-resistant consensus mechanisms.

Jump to

Keyboard shortcuts

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