ceremonyclient/consensus/vote_collectors.go
Cassandra Heart c797d482f9
v2.1.0.5 (#457)
* wip: conversion of hotstuff from flow into Q-oriented model

* bulk of tests

* remaining non-integration tests

* add integration test, adjust log interface, small tweaks

* further adjustments, restore full pacemaker shape

* add component lifecycle management+supervisor

* further refinements

* resolve timeout hanging

* mostly finalized state for consensus

* bulk of engine swap out

* lifecycle-ify most types

* wiring nearly complete, missing needed hooks for proposals

* plugged in, vetting message validation paths

* global consensus, plugged in and verified

* app shard now wired in too

* do not decode empty keys.yml (#456)

* remove obsolete engine.maxFrames config parameter (#454)

* default to Info log level unless debug is enabled (#453)

* respect config's  "logging" section params, remove obsolete single-file logging (#452)

* Trivial code cleanup aiming to reduce Go compiler warnings (#451)

* simplify range traversal

* simplify channel read for single select case

* delete rand.Seed() deprecated in Go 1.20 and no-op as of Go 1.24

* simplify range traversal

* simplify channel read for single select case

* remove redundant type from array

* simplify range traversal

* simplify channel read for single select case

* RC slate

* finalize 2.1.0.5

* Update comments in StrictMonotonicCounter

Fix comment formatting and clarify description.

---------

Co-authored-by: Black Swan <3999712+blacks1ne@users.noreply.github.com>
2025-11-11 05:00:17 -06:00

59 lines
2.3 KiB
Go

package consensus
import (
"source.quilibrium.com/quilibrium/monorepo/consensus/models"
"source.quilibrium.com/quilibrium/monorepo/lifecycle"
)
// VoteCollectors is an interface which allows VoteAggregator to interact with
// collectors structured by rank.
// Implementations of this interface are responsible for state transitions of
// `VoteCollector`s and pruning of stale and outdated collectors by rank.
type VoteCollectors[StateT models.Unique, VoteT models.Unique] interface {
lifecycle.Component
// GetOrCreateCollector retrieves the consensus.VoteCollector for the specified
// rank or creates one if none exists.
// It returns:
// - (collector, true, nil) if no collector can be found by the rank, and a
// new collector was created.
// - (collector, false, nil) if the collector can be found by the rank
// - (nil, false, error) if running into any exception creating the vote
// collector state machine
// Expected error returns during normal operations:
// * models.BelowPrunedThresholdError - in case rank is lower than last
// pruned rank
GetOrCreateCollector(rank uint64) (
collector VoteCollector[StateT, VoteT],
created bool,
err error,
)
// PruneUpToRank prunes the vote collectors with ranks _below_ the given
// value, i.e. we only retain and process whose rank is equal or larger than
// `lowestRetainedRank`. If `lowestRetainedRank` is smaller than the previous
// value, the previous value is kept and the method call is a NoOp.
PruneUpToRank(lowestRetainedRank uint64)
}
// Workers queues and processes submitted tasks. We explicitly do not
// expose any functionality to terminate the worker pool.
type Workers interface {
// Submit enqueues a function for a worker to execute. Submit will not block
// regardless of the number of tasks submitted. Each task is immediately
// given to an available worker or queued otherwise. Tasks are processed in
// FiFO order.
Submit(task func())
}
// Workerpool adds the functionality to terminate the workers to the
// Workers interface.
type Workerpool interface {
Workers
// StopWait stops the worker pool and waits for all queued tasks to
// complete. No additional tasks may be submitted, but all pending tasks are
// executed by workers before this function returns.
StopWait()
}