Documentation
¶
Index ¶
- func RejectReason(err error) string
- type Round
- type Storage
- func (s *Storage) AddVote(data *instruction.Data, signer common.Address, signature []byte) (*voting.Receipt, error)
- func (s *Storage) CurrentMaxVotingWeightBips() float64
- func (s *Storage) CurrentRoundInitiatorCount() int
- func (s *Storage) CurrentRoundProviderVoterCount() int
- func (s *Storage) CurrentRoundTopPending(n int) []limiter.VoterPending
- func (s *Storage) CurrentVotedWeightBips() float64
- func (s *Storage) CurrentVotingThresholdBips() float64
- func (s *Storage) MaxConsensusEpoch() uint32
- func (s *Storage) OldestStoredEpoch() (uint32, bool)
- func (s *Storage) StoreNewRound(policy *policy.SigningPolicy)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RejectReason ¶ added in v0.0.19
RejectReason maps an AddVote error to a bounded label for instructions_rejected_total; unmatched errors return "other". The label set is mirrored by the metrics pre-init (metrics.New) — keep the two in sync.
Types ¶
type Round ¶
type Round struct {
Voting votingSync // instructionID -> instructionHash -> VoteBox
// contains filtered or unexported fields
}
Round holds all voting activity that belongs to one signing policy (reward epoch).
func (*Round) MaxVotingWeightBips ¶ added in v0.0.21
MaxVotingWeightBips returns the highest provider weight accumulated by any single voting this epoch, in BIPS of the policy's total voter weight.
func (*Round) ProposerCount ¶ added in v0.0.19
ProposerCount returns the number of distinct initiators (proposers) seen this epoch.
func (*Round) ProviderVoterCount ¶ added in v0.0.19
ProviderVoterCount returns the number of distinct data-provider voters seen this epoch.
func (*Round) ThresholdBips ¶ added in v0.0.21
ThresholdBips returns the policy's finalization threshold in BIPS of its total voter weight. Policy-derived, so it is independent of participation.
func (*Round) TopPendingProposals ¶ added in v0.0.19
func (r *Round) TopPendingProposals(n int) []limiter.VoterPending
TopPendingProposals returns up to n voters with the most unfinalised proposals this epoch, highest first, excluding voters with none.
func (*Round) VotedWeightBips ¶ added in v0.0.21
VotedWeightBips returns the combined signing-policy weight of this epoch's data-provider voters, in BIPS of the policy's total voter weight.
type Storage ¶
type Storage struct {
*storage.Cyclic[uint32, *Round]
// Channel for actions created by voting.
Out chan *types.Action
// contains filtered or unexported fields
}
Storage holds one voting Round per signing policy in a cyclic buffer; storing a new round at ID%size overwrites the previous occupant.
func NewStorage ¶
func NewStorage(ctx context.Context, config *config.Voting, meta meta.Meta, m *metrics.Metrics) *Storage
NewStorage creates a voting Storage backed by a cyclic buffer sized by config.HistorySize. ctx is the service-lifetime context that bounds per-box goroutines created during AddVote. m may be nil or disabled.
func (*Storage) AddVote ¶
func (s *Storage) AddVote(data *instruction.Data, signer common.Address, signature []byte) (*voting.Receipt, error)
AddVote records a vote in the appropriate box and returns a signed receipt. Returns an error if the round is missing; opens a new VoteBox for an unseen instruction hash when the proposer is within the limiter's per-voter cap.
func (*Storage) CurrentMaxVotingWeightBips ¶ added in v0.0.21
CurrentMaxVotingWeightBips returns the highest provider weight any single voting accumulated in the reported reward epoch, in BIPS of the policy total, or 0 if no round is stored. Round selection matches CurrentVotedWeightBips. Read at scrape time.
func (*Storage) CurrentRoundInitiatorCount ¶ added in v0.0.19
CurrentRoundInitiatorCount returns the distinct initiator count for the reported reward epoch, or 0 if no round is stored. Reports the current reward epoch's round, falling back to its predecessor only while the current round has no accepted provider votes. Read at scrape time.
func (*Storage) CurrentRoundProviderVoterCount ¶ added in v0.0.19
CurrentRoundProviderVoterCount returns the distinct data-provider-voter count for the reported reward epoch, or 0 if no round is stored. Reports the current reward epoch's round, falling back to its predecessor only while the current round has no accepted provider votes. Read at scrape time.
func (*Storage) CurrentRoundTopPending ¶ added in v0.0.19
func (s *Storage) CurrentRoundTopPending(n int) []limiter.VoterPending
CurrentRoundTopPending returns up to n voters with the most unfinalised proposals in the latest reward epoch, or nil if no round is stored. During an epoch-announcement overlap it merges the newest resident round and its predecessor, taking the max pending per provider (not the sum, so a provider present in both rounds is not double-counted). Read at scrape time.
func (*Storage) CurrentVotedWeightBips ¶ added in v0.0.21
CurrentVotedWeightBips returns the combined weight of the reported reward epoch's data-provider voters in BIPS of the policy total, or 0 if no round is stored. Reports the current reward epoch's round, falling back to its predecessor only while the current round has no accepted provider votes. Read at scrape time.
func (*Storage) CurrentVotingThresholdBips ¶ added in v0.0.21
CurrentVotingThresholdBips returns the reported reward epoch's finalization threshold in BIPS of its policy total voter weight, or 0 if no round is stored. Round selection matches CurrentVotedWeightBips, so the three weight gauges are comparable. Read at scrape time.
func (*Storage) MaxConsensusEpoch ¶ added in v0.0.20
MaxConsensusEpoch returns the highest reward epoch reached by consensus, or 0 if none yet.
func (*Storage) OldestStoredEpoch ¶ added in v0.0.19
OldestStoredEpoch returns the oldest reward epoch with a round still resident in the cyclic buffer, with ok=false when none is stored. The newest resident epoch is the active one, already exposed as policy_active_reward_epoch. Read at scrape time.
func (*Storage) StoreNewRound ¶
func (s *Storage) StoreNewRound(policy *policy.SigningPolicy)
StoreNewRound creates and stores a round for the policy, overwriting the previous occupant at the same cyclic slot. A no-op if a round for this policy already exists.