Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryPhotonSampler ¶
type BinaryPhotonSampler struct {
// contains filtered or unexported fields
}
BinaryPhotonSampler implements binary consensus sampling (Previously BinaryPoll in Avalanche)
Binary photon sampling chooses between exactly two options, like a photon passing through a beam splitter.
func NewBinaryPhotonSampler ¶
func NewBinaryPhotonSampler(k int, seed int64) *BinaryPhotonSampler
NewBinaryPhotonSampler creates a new binary photon sampler
func (*BinaryPhotonSampler) GetK ¶
func (b *BinaryPhotonSampler) GetK() int
GetK returns the sample size
func (*BinaryPhotonSampler) Reset ¶
func (b *BinaryPhotonSampler) Reset()
Reset clears the sampler state
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory creates photon samplers with specific configurations (Previously PollFactory in Avalanche)
func (*Factory) New ¶
func (f *Factory) New(samplerType SamplerType) Sampler
New creates a sampler of the specified type
func (*Factory) WithTerminationThreshold ¶
WithTerminationThreshold sets the early termination threshold
type PhotonQuery ¶
type PhotonQuery struct {
RequestID uint32
ChainID ids.ID
Height uint64
Containers []ids.ID // Options being queried
}
PhotonQuery represents a query sent to validators (Previously known as Poll message)
type PhotonReflection ¶
type PhotonReflection struct {
RequestID uint32
ChainID ids.ID
Height uint64
Container ids.ID // The validator's choice
Confidence int // Confidence level
}
PhotonReflection represents a response from a validator (Previously known as Vote message)
type Response ¶
type Response struct {
NodeID ids.NodeID
Preference ids.ID // The validator's preference
Confidence int // Confidence level (0-100)
}
Response represents a validator's response to a photon query (Previously known as Vote in Avalanche consensus)
type Sampler ¶
type Sampler interface {
// Sample returns a sample of K validators to query
// This is like emitting photons to specific targets
Sample(ctx context.Context, validatorSet set.Set[ids.NodeID], k int) (set.Set[ids.NodeID], error)
// GetK returns the sample size
GetK() int
// Reset clears any internal state
Reset()
}
Sampler represents photonic sampling of validators (Previously known as Poll in Avalanche consensus)
The photon sampler emits "photons" (queries) to a sample of K validators and collects their "reflections" (responses).
type SamplerType ¶
type SamplerType int
SamplerType identifies the type of photon sampler
const ( Binary SamplerType = iota Unary )
type UnaryPhotonSampler ¶
type UnaryPhotonSampler struct {
// contains filtered or unexported fields
}
UnaryPhotonSampler implements unary consensus sampling (Previously UnaryPoll in Avalanche)
Unary photon sampling is used when there's only one option, like measuring photon presence/absence rather than direction.
func NewUnaryPhotonSampler ¶
func NewUnaryPhotonSampler(k int, seed int64, termThreshold int) *UnaryPhotonSampler
NewUnaryPhotonSampler creates a new unary photon sampler
func (*UnaryPhotonSampler) GetK ¶
func (u *UnaryPhotonSampler) GetK() int
GetK returns the sample size
func (*UnaryPhotonSampler) RecordEarlyTermination ¶
func (u *UnaryPhotonSampler) RecordEarlyTermination(containerID ids.ID)
RecordEarlyTermination records when a unary query terminates early
func (*UnaryPhotonSampler) Reset ¶
func (u *UnaryPhotonSampler) Reset()
Reset clears the sampler state