pub struct BootstrapState {
pub drained: bool,
pub pending_peer_requests: usize,
pub pending_keys: HashSet<XorName>,
pub capacity_rejected_sources: HashMap<PeerId, Instant>,
}Expand description
Bootstrap drain state tracking (Section 16).
Fields§
§drained: boolWhether bootstrap is complete (all peer requests done, queues empty).
pending_peer_requests: usizeNumber of bootstrap peer requests still pending.
pending_keys: HashSet<XorName>Keys discovered during bootstrap that are still in the verification / fetch pipeline.
capacity_rejected_sources: HashMap<PeerId, Instant>Peers whose bootstrap admission unit had one or more hints rejected at
capacity, mapped to the time of their first such rejection. Each
entry means “this source still owes us at least one re-hinted key after
the queues drain”.
check_bootstrap_drained refuses to claim the node fully drained
while this map is non-empty: a source’s presence is cleared by its
next admission cycle that completes with zero capacity rejections
(i.e. the source successfully re-delivered everything that
previously overflowed). Tracking per-source instead of a global
counter prevents one peer’s rejection from being “cleared” by an
unrelated peer’s clean cycle.
The recorded time is first-seen and never refreshed (see
Self::note_capacity_rejected). A repeat rejection re-asserts that
the source still owes work, but it must not restart the expiry clock:
a source that keeps overflowing the queue would otherwise keep its own
record permanently fresh and wedge bootstrap open forever, which
disables auditing (Invariant 19) for the lifetime of the pressure.
First-seen semantics bound the wedge at
ReplicationConfig::capacity_rejected_max_age regardless of how a
source behaves.
Entries expire once that first-rejection time is older than
capacity_rejected_max_age (see
super::bootstrap::expire_capacity_rejected): the source either
abandoned re-delivery, is overflowing us faster than it can re-deliver,
or its PeerRemoved cleanup raced the recording of the rejection and
left an entry no future event can clear. Expiring an entry means
bootstrap may drain without ever admitting keys that source
advertised. This is acceptable and consistent with
update_bootstrap_after_peer_removed, which already forfeits a
departed source’s owed work wholesale — post-bootstrap periodic
neighbor sync and the audit/repair pipeline are the recovery path for
missed keys.
Sources whose key was displaced by another sender reclaiming a borrowed slot are deliberately NOT recorded here: fairness reclamation is our decision, not a failure of theirs, and stamping the victim lets a third party block our drain through an unrelated honest peer. The displaced key is forfeited to the same post-bootstrap recovery path.
Implementations§
Source§impl BootstrapState
impl BootstrapState
Sourcepub fn note_capacity_rejected(&mut self, source: PeerId, now: Instant) -> bool
pub fn note_capacity_rejected(&mut self, source: PeerId, now: Instant) -> bool
Record that source had one or more hints rejected at capacity.
First-seen semantics: a repeat rejection re-asserts the debt but leaves
the original timestamp alone, so the expiry clock in
super::bootstrap::expire_capacity_rejected measures how long the
source has owed us work rather than how recently it last overflowed us.
See Self::capacity_rejected_sources for why refreshing wedges
bootstrap open.
Returns whether this was the source’s first outstanding rejection.
Sourcepub fn is_drained(&self) -> bool
pub fn is_drained(&self) -> bool
Check if bootstrap is drained.
Only returns true after super::bootstrap::check_bootstrap_drained or
super::bootstrap::mark_bootstrap_drained has explicitly set the flag. A fresh
BootstrapState is NOT drained — the audit loop must wait until
bootstrap work has actually completed (Invariant 19).
Sourcepub fn remove_key(&mut self, key: &XorName)
pub fn remove_key(&mut self, key: &XorName)
Remove a key from the bootstrap pending set.
Called when a key terminally leaves the verification/fetch pipeline (stored, abandoned, quorum failed, etc.) so the drain check set shrinks incrementally rather than being re-scanned in full.
Trait Implementations§
Source§impl Debug for BootstrapState
impl Debug for BootstrapState
Auto Trait Implementations§
impl Freeze for BootstrapState
impl RefUnwindSafe for BootstrapState
impl Send for BootstrapState
impl Sync for BootstrapState
impl Unpin for BootstrapState
impl UnsafeUnpin for BootstrapState
impl UnwindSafe for BootstrapState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more