focus

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryFocusTracker

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

BinaryFocusTracker tracks confidence for binary consensus (Previously BinaryConfidence in Avalanche)

Binary focus tracking is like a lens focusing between two possible states - as consensus forms, focus sharpens on one choice through beta consecutive rounds.

func NewBinaryFocusTracker

func NewBinaryFocusTracker(beta int) *BinaryFocusTracker

NewBinaryFocusTracker creates a new binary focus tracker

func (*BinaryFocusTracker) GetBeta

func (b *BinaryFocusTracker) GetBeta() int

GetBeta returns the beta parameter

func (*BinaryFocusTracker) GetChoice

func (b *BinaryFocusTracker) GetChoice() ids.ID

GetChoice returns the choice we're focusing on

func (*BinaryFocusTracker) GetConfidence

func (b *BinaryFocusTracker) GetConfidence() int

GetConfidence returns current confidence level (0 to Beta)

func (*BinaryFocusTracker) GetFocusState

func (b *BinaryFocusTracker) GetFocusState() *FocusState

GetFocusState returns the current focus state

func (*BinaryFocusTracker) GetSuccessRate

func (b *BinaryFocusTracker) GetSuccessRate() int

GetSuccessRate returns the overall success rate (0-100)

func (*BinaryFocusTracker) IsFocused

func (b *BinaryFocusTracker) IsFocused() bool

IsFocused returns true if fully focused (beta rounds achieved)

func (*BinaryFocusTracker) RecordPoll

func (b *BinaryFocusTracker) RecordPoll(successful bool, choice ids.ID)

RecordPoll records the result of a photon sampling round

func (*BinaryFocusTracker) Reset

func (b *BinaryFocusTracker) Reset()

Reset clears confidence state

type Confidence

type Confidence interface {
	// RecordPoll records the result of a photon sampling round
	RecordPoll(successful bool, choice ids.ID)

	// GetConfidence returns current confidence level (0 to Beta)
	GetConfidence() int

	// IsFocused returns true if fully focused (beta rounds achieved)
	IsFocused() bool

	// GetBeta returns the beta parameter
	GetBeta() int

	// GetChoice returns the choice we're focusing on
	GetChoice() ids.ID

	// Reset clears confidence state
	Reset()
}

Confidence represents focus intensity for beta-round tracking (Previously known as Confidence in Avalanche consensus)

As photonic consensus progresses, the "focus" intensifies through beta consecutive rounds of agreement, eventually achieving finality when fully focused.

func NewFromConfig

func NewFromConfig(cfg Config) Confidence

NewFromConfig creates a focus tracker from configuration

type Config

type Config struct {
	Type FocusType
	Beta int
}

Config represents focus tracking configuration

type Factory

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

Factory creates focus tracking mechanisms (Previously ConfidenceFactory in Avalanche)

func NewFactory

func NewFactory(beta int) *Factory

NewFactory creates a new focus tracker factory

func (*Factory) New

func (f *Factory) New(focusType FocusType) Confidence

New creates a focus tracker of the specified type

func (*Factory) NewBinary

func (f *Factory) NewBinary() Confidence

NewBinary creates a binary focus tracker

func (*Factory) NewUnary

func (f *Factory) NewUnary() Confidence

NewUnary creates a unary focus tracker

type FocusState

type FocusState struct {
	Choice           ids.ID // The choice being focused on
	ConsecutivePolls int    // Number of consecutive successful polls
	Beta             int    // Required consecutive polls for focus
	TotalPolls       int    // Total polls conducted
	SuccessfulPolls  int    // Total successful polls
}

FocusState represents the current focusing state (Previously ConfidenceState)

func (*FocusState) GetIntensity

func (f *FocusState) GetIntensity() int

GetIntensity returns focus intensity as percentage (0-100)

func (*FocusState) IsFocused

func (f *FocusState) IsFocused() bool

IsFocused returns true if we've achieved focus

type FocusType

type FocusType int

FocusType identifies the type of focus tracking

const (
	BinaryFocus FocusType = iota
	UnaryFocus
	MultiChoiceFocus
)

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
}

Parameters holds all photonic consensus parameters (Maps to Avalanche consensus Parameters)

type UnaryFocusTracker

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

UnaryFocusTracker tracks confidence for unary consensus (Previously UnaryConfidence in Avalanche)

Unary focus tracking is like measuring photon intensity - we're not choosing between options but confirming presence through repeated observations.

func NewUnaryFocusTracker

func NewUnaryFocusTracker(beta int) *UnaryFocusTracker

NewUnaryFocusTracker creates a new unary focus tracker

func (*UnaryFocusTracker) GetBeta

func (u *UnaryFocusTracker) GetBeta() int

GetBeta returns the beta parameter

func (*UnaryFocusTracker) GetChoice

func (u *UnaryFocusTracker) GetChoice() ids.ID

GetChoice returns the choice we're focusing on

func (*UnaryFocusTracker) GetConfidence

func (u *UnaryFocusTracker) GetConfidence() int

GetConfidence returns current confidence level (0 to Beta)

func (*UnaryFocusTracker) GetRecentSuccessRate

func (u *UnaryFocusTracker) GetRecentSuccessRate() int

GetRecentSuccessRate returns success rate over recent history

func (*UnaryFocusTracker) IsFocused

func (u *UnaryFocusTracker) IsFocused() bool

IsFocused returns true if fully focused (beta rounds achieved)

func (*UnaryFocusTracker) RecordPoll

func (u *UnaryFocusTracker) RecordPoll(successful bool, choice ids.ID)

RecordPoll records the result of a photon sampling round

func (*UnaryFocusTracker) Reset

func (u *UnaryFocusTracker) Reset()

Reset clears confidence state

func (*UnaryFocusTracker) TimeSinceLastPoll

func (u *UnaryFocusTracker) TimeSinceLastPoll() time.Duration

TimeSinceLastPoll returns duration since last poll

Jump to

Keyboard shortcuts

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