Expand description
This guardian’s view of its peers’ availability.
A peer counts as available in a 1-minute slot if it sent us any AlephBFT
message in it. Every running peer sends consensus traffic while the
federation is active, including a slow one that lags behind and still runs
an older session, while an offline or frozen peer, or one whose consensus
is stuck, sends nothing. A slot in which we heard from fewer than
threshold - 1 peers means the federation was idle, or we were down or
cut off ourselves, so it does not count.
PeerActivity counts slots in memory; persist_peer_availability
folds them every 10 minutes into exponential moving averages with the time
constants in PEER_AVAILABILITY_WINDOWS_SECS, persisted as
PeerAvailabilityState.
Structs§
- Availability
Timing 🔒 - Availability
Tracker - Serializes resets and writes, including taking the buffered samples.
- Average 🔒
- An
f64stored by its bits, so the averages survive restarts exactly. - Observed
Activity - What
PeerActivityobserved since it was last taken. - Peer
Activity - Slots of consensus traffic per peer since the last
PeerActivity::take. - Peer
Availability State - Moving averages of each peer’s availability, one per window.
Functions§
- persist_
peer_ availability - Folds the
PeerActivityinto the persistedPeerAvailabilityStateevery 10 minutes, or every 10 seconds in tests. A restart loses at most one interval of activity. - report
- report_
with_ timestamp - Read the local report, including reset peers, and its last persistence time from the same database snapshot. Zero means no observations were saved yet.
- to_bps 🔒