Documentation
¶
Index ¶
- type BeamBlock
- func (b *BeamBlock) Accept() error
- func (b *BeamBlock) BeamHeight() uint64
- func (b *BeamBlock) BeamScore() uint64
- func (b *BeamBlock) Bytes() []byte
- func (b *BeamBlock) Height() uint64
- func (b *BeamBlock) ID() string
- func (b *BeamBlock) IncrementPhotons()
- func (b *BeamBlock) Parent() ids.ID
- func (b *BeamBlock) Photons() int
- func (b *BeamBlock) Reject() error
- func (b *BeamBlock) Status() choices.Status
- func (b *BeamBlock) Timestamp() time.Time
- func (b *BeamBlock) UpdateBeamScore(score uint64)
- func (b *BeamBlock) Verify(ctx context.Context) error
- type BeamBlockWrapper
- type BeamMetrics
- type BeamState
- type Block
- type Engine
- func (e *Engine) Add(ctx context.Context, block Block) error
- func (e *Engine) Finalized() []ids.ID
- func (e *Engine) HealthCheck(ctx context.Context) (Health, error)
- func (e *Engine) IsFinalized(blockID ids.ID) bool
- func (e *Engine) Preferred() ids.ID
- func (e *Engine) RecordPoll(ctx context.Context, votes map[ids.ID]int) error
- func (e *Engine) Vote(ctx context.Context, blockID ids.ID) error
- type Health
- type Linearizer
- type Parameters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeamBlock ¶
type BeamBlock struct {
// Embedded chain block for compatibility
chain.Block
// contains filtered or unexported fields
}
BeamBlock implements the Block interface for beam consensus (Previously a concrete implementation of snowman.Block)
func NewBeamBlock ¶
func NewBeamBlock( id ids.ID, parentID ids.ID, height uint64, timestamp time.Time, bytes []byte, ) *BeamBlock
NewBeamBlock creates a new beam block
func (*BeamBlock) BeamHeight ¶
BeamHeight returns the block's position in the beam
func (*BeamBlock) IncrementPhotons ¶
func (b *BeamBlock) IncrementPhotons()
IncrementPhotons increments the photon query count
func (*BeamBlock) UpdateBeamScore ¶
UpdateBeamScore updates the consensus score
type BeamBlockWrapper ¶
BeamBlockWrapper wraps an existing chain.Block for beam consensus
func WrapBlock ¶
func WrapBlock(block chain.Block, height uint64) *BeamBlockWrapper
WrapBlock wraps an existing chain block for beam consensus
func (*BeamBlockWrapper) BeamHeight ¶
func (w *BeamBlockWrapper) BeamHeight() uint64
BeamHeight returns the block's position in the beam
func (*BeamBlockWrapper) BeamScore ¶
func (w *BeamBlockWrapper) BeamScore() uint64
BeamScore returns the block's consensus score
func (*BeamBlockWrapper) Photons ¶
func (w *BeamBlockWrapper) Photons() int
Photons returns the number of photon queries for this block
type BeamMetrics ¶
type BeamMetrics struct {
BlocksAdded uint64
BlocksFinalized uint64
PollsProcessed uint64
BeamSplits uint64 // Times the beam split (reorgs)
AveragePollTime time.Duration
AverageFocusTime time.Duration
}
BeamMetrics tracks beam consensus performance
type BeamState ¶
type BeamState struct {
PreferredID ids.ID
PreferredHeight uint64
FinalizedID ids.ID
FinalizedHeight uint64
OutstandingBlocks int
BeamIntensity int // Consensus strength (0-100)
}
BeamState represents the current state of linear consensus
type Block ¶
type Block interface {
chain.Block
// BeamHeight returns the block's position in the beam
BeamHeight() uint64
// BeamScore returns the block's consensus score
BeamScore() uint64
// Photons returns the number of photon queries for this block
Photons() int
}
Block represents a block in the linear beam (Previously snowman.Block)
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements the beam linearizer for linear chain consensus (Previously Topological/Snowman++ in Avalanche)
func NewEngine ¶
func NewEngine(params Parameters) *Engine
NewEngine creates a new beam consensus engine
func (*Engine) HealthCheck ¶
HealthCheck returns consensus health metrics
func (*Engine) IsFinalized ¶
IsFinalized checks if a block has been finalized
func (*Engine) RecordPoll ¶
RecordPoll records the result of photon sampling
type Health ¶
type Health struct {
Healthy bool
BeamCoherence float64 // 0-1, how coherent the beam is
FocusStrength int // Current focus strength
LastPollTime time.Time
ConsecutivePolls int
OutstandingBlocks int
}
Health represents consensus health metrics
type Linearizer ¶
type Linearizer interface {
// Add a new block to the beam
Add(ctx context.Context, block Block) error
// Vote for a block preference
Vote(ctx context.Context, blockID ids.ID) error
// RecordPoll records the result of photon sampling
RecordPoll(ctx context.Context, votes map[ids.ID]int) error
// Preferred returns the current preferred block
Preferred() ids.ID
// Finalized returns finalized blocks since last call
Finalized() []ids.ID
// IsFinalized checks if a block has been finalized
IsFinalized(blockID ids.ID) bool
// HealthCheck returns consensus health metrics
HealthCheck(ctx context.Context) (Health, error)
}
Linearizer represents beam-based linear chain consensus (Previously known as Snowman in Avalanche)
The beam linearizer ensures blocks form a single coherent beam of light, with each block building on exactly one parent, creating a linear history.
type Parameters ¶
type Parameters struct {
K int // Photon sample size
AlphaPreference int // Wave threshold for preference
AlphaConfidence int // Wave threshold for confidence
Beta int // Focus rounds for finality
MaxPollTime time.Duration // Maximum time for a poll
}
Parameters configures the beam engine