round

package
v0.8.83 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0, AGPL-3.0-or-later, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Participant

type Participant interface {
	// Ballot returns this participant's vote on the subject. The bool is
	// false to abstain, which happens when the subject cannot be judged.
	Ballot(reportID string, subject event.ReportEvent) (vote.Event, bool, error)
	// Broadcast publishes a ballot (or a Final announcement) to the other
	// participants.
	Broadcast(v vote.Event) error
	// Decided is invoked exactly once per round, on the single
	// participant that carries the decision.
	Decided(subject event.ReportEvent, outcome vote.Event, voters []domain.ID)
}

Participant is the local voter a round acts for. This package owns the voting protocol — who votes, when, who carries the decision — and knows nothing of what a ballot means or what happens once a round decides: everything domain-specific sits behind this interface, implemented by the caller.

type Registry

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

Registry is a participant's collection of live vote rounds. It owns what spans rounds — which ones are still open, which are already spent, and how many participants are out there — and hands each round the one number it cannot derive alone: when this participant's turn to vote comes up.

Locking: Registry.mx may be held while calling into a round, never the other way around. A round calls back (onDone) without holding its own lock, so the two never deadlock.

func NewRegistry

func NewRegistry(self string, member Participant, schedule Schedule) *Registry

func (*Registry) AddVote

func (rs *Registry) AddVote(v vote.Event)

AddVote routes an incoming ballot to its round, opening one if the ballot arrived before the subject did.

func (*Registry) Len

func (rs *Registry) Len() int

Len reports how many rounds are still live.

func (*Registry) MarkFinalized

func (rs *Registry) MarkFinalized(id, by string) bool

MarkFinalized records that a round participant carried the decision and drops this copy, cancelling its takeover timer. It reports whether the announcement was honored.

A Final is honored only for a round this node is holding whose votes include the announcer: the chair and every backup voted, so a legitimate Final always comes from a voter. A Final from a non-voter — or for a round this node never opened — is ignored and, crucially, is not recorded as finalized. Report ids are a public hash of the report, so trusting an unverified Final would let any node pre-seed the finalized set for an id it can predict and silence the real report before it is ever judged.

func (*Registry) Open

func (rs *Registry) Open(rep event.ReportEvent)

Open starts (or joins) the round for a subject and schedules this participant's vote at its deterministic turn.

func (*Registry) Peers

func (rs *Registry) Peers() []string

Peers lists the participants seen voting recently. It is a passive observation used to scale volunteer delays and to give an auditor somebody to ask; no trust decision reads it.

func (*Registry) StopAll

func (rs *Registry) StopAll()

type Schedule

type Schedule struct {
	Window   time.Duration
	Failover time.Duration
	Step     time.Duration
}

Schedule carries a round's clock settings as state, so callers (and tests) can stretch them without turning the constants above into mutable globals.

func DefaultSchedule

func DefaultSchedule() Schedule

Jump to

Keyboard shortcuts

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