Documentation
¶
Index ¶
- type Config
- type DynamicWaveThreshold
- func (d *DynamicWaveThreshold) AddVote(nodeID ids.NodeID, choice ids.ID) bool
- func (d *DynamicWaveThreshold) CheckConfidence() (ids.ID, bool)
- func (d *DynamicWaveThreshold) CheckPreference() (ids.ID, bool)
- func (d *DynamicWaveThreshold) GetLeader() (ids.ID, int)
- func (d *DynamicWaveThreshold) GetThreshold() int
- func (d *DynamicWaveThreshold) GetTotalVotes() int
- func (d *DynamicWaveThreshold) GetVoteCount(choice ids.ID) int
- func (d *DynamicWaveThreshold) Reset()
- func (d *DynamicWaveThreshold) SetMode(preferenceMode bool)
- type Factory
- type StaticWaveThreshold
- func (s *StaticWaveThreshold) AddVote(nodeID ids.NodeID, choice ids.ID) bool
- func (s *StaticWaveThreshold) GetLeader() (ids.ID, int)
- func (s *StaticWaveThreshold) GetThreshold() int
- func (s *StaticWaveThreshold) GetTotalVotes() int
- func (s *StaticWaveThreshold) GetVoteCount(choice ids.ID) int
- func (s *StaticWaveThreshold) GetWavePattern() *WavePattern
- func (s *StaticWaveThreshold) Reset()
- type Threshold
- type ThresholdType
- type WavePattern
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Type ThresholdType
AlphaPreference int
AlphaConfidence int
}
Config represents wave threshold configuration
type DynamicWaveThreshold ¶
type DynamicWaveThreshold struct {
// contains filtered or unexported fields
}
DynamicWaveThreshold implements decoupled alpha thresholding (Previously DynamicQuorum/DecoupledQuorum in Avalanche)
Uses separate thresholds for preference (alpha1) and confidence (alpha2), allowing for more nuanced consensus detection through wave interference.
func NewDynamicWaveThreshold ¶
func NewDynamicWaveThreshold(alphaPreference, alphaConfidence int) *DynamicWaveThreshold
NewDynamicWaveThreshold creates a threshold with decoupled alphas
func (*DynamicWaveThreshold) AddVote ¶
AddVote adds a vote and returns true if current threshold is reached
func (*DynamicWaveThreshold) CheckConfidence ¶
func (d *DynamicWaveThreshold) CheckConfidence() (ids.ID, bool)
CheckConfidence returns true if any choice meets confidence threshold
func (*DynamicWaveThreshold) CheckPreference ¶
func (d *DynamicWaveThreshold) CheckPreference() (ids.ID, bool)
CheckPreference returns true if any choice meets preference threshold
func (*DynamicWaveThreshold) GetLeader ¶
func (d *DynamicWaveThreshold) GetLeader() (ids.ID, int)
GetLeader returns the current leading choice and its vote count
func (*DynamicWaveThreshold) GetThreshold ¶
func (d *DynamicWaveThreshold) GetThreshold() int
GetThreshold returns the current active threshold
func (*DynamicWaveThreshold) GetTotalVotes ¶
func (d *DynamicWaveThreshold) GetTotalVotes() int
GetTotalVotes returns total votes received
func (*DynamicWaveThreshold) GetVoteCount ¶
func (d *DynamicWaveThreshold) GetVoteCount(choice ids.ID) int
GetVoteCount returns votes for a specific choice
func (*DynamicWaveThreshold) SetMode ¶
func (d *DynamicWaveThreshold) SetMode(preferenceMode bool)
SetMode switches between preference and confidence modes
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory creates wave threshold mechanisms (Previously QuorumFactory in Avalanche)
func NewFactory ¶
NewFactory creates a new wave threshold factory
func (*Factory) New ¶
func (f *Factory) New(thresholdType ThresholdType) Threshold
New creates a threshold of the specified type
func (*Factory) NewDynamic ¶
NewDynamic creates a dynamic wave threshold with decoupled alphas
type StaticWaveThreshold ¶
type StaticWaveThreshold struct {
// contains filtered or unexported fields
}
StaticWaveThreshold implements fixed alpha thresholding (Previously StaticQuorum in Avalanche)
Uses a fixed threshold for determining when constructive interference (consensus) has been achieved.
func NewStaticWaveThreshold ¶
func NewStaticWaveThreshold(alpha int) *StaticWaveThreshold
NewStaticWaveThreshold creates a threshold with fixed alpha
func (*StaticWaveThreshold) GetLeader ¶
func (s *StaticWaveThreshold) GetLeader() (ids.ID, int)
GetLeader returns the current leading choice and its vote count
func (*StaticWaveThreshold) GetThreshold ¶
func (s *StaticWaveThreshold) GetThreshold() int
GetThreshold returns the alpha threshold
func (*StaticWaveThreshold) GetTotalVotes ¶
func (s *StaticWaveThreshold) GetTotalVotes() int
GetTotalVotes returns total votes received
func (*StaticWaveThreshold) GetVoteCount ¶
func (s *StaticWaveThreshold) GetVoteCount(choice ids.ID) int
GetVoteCount returns votes for a specific choice
func (*StaticWaveThreshold) GetWavePattern ¶
func (s *StaticWaveThreshold) GetWavePattern() *WavePattern
GetWavePattern returns the current voting state
type Threshold ¶
type Threshold interface {
// AddVote adds a vote and returns if threshold is reached
AddVote(nodeID ids.NodeID, choice ids.ID) bool
// GetThreshold returns the current alpha threshold
GetThreshold() int
// GetVoteCount returns votes for a specific choice
GetVoteCount(choice ids.ID) int
// GetTotalVotes returns total votes received
GetTotalVotes() int
// GetLeader returns the current leading choice and its vote count
GetLeader() (ids.ID, int)
// Reset clears all votes
Reset()
}
Threshold represents wave interference patterns for vote counting (Previously known as Quorum in Avalanche consensus)
When photon reflections (votes) return, they create interference patterns. Constructive interference above the threshold indicates consensus forming.
func NewFromConfig ¶
NewFromConfig creates a threshold from configuration
type ThresholdType ¶
type ThresholdType int
ThresholdType identifies the type of threshold mechanism
const ( Static ThresholdType = iota Dynamic Adaptive )
type WavePattern ¶
type WavePattern struct {
Choices map[ids.ID]int // Vote counts per choice
TotalVotes int
Threshold int // Alpha threshold
}
WavePattern represents the voting state at a given moment (Previously QuorumState)
func (*WavePattern) GetAmplitude ¶
func (w *WavePattern) GetAmplitude(choice ids.ID) int
GetAmplitude returns the "amplitude" (vote count) for a choice
func (*WavePattern) IsConstructive ¶
func (w *WavePattern) IsConstructive() bool
IsConstructive returns true if the pattern shows constructive interference (i.e., one choice has exceeded the threshold)