pub struct InterestTable { /* private fields */ }Expand description
The per-hop interest table (plan §4.3).
Implementations§
Source§impl InterestTable
impl InterestTable
Sourcepub fn new(max_interests_per_peer: usize) -> Self
pub fn new(max_interests_per_peer: usize) -> Self
Empty table with the given per-downstream cap
(max_interests_per_peer, plan §5 — default 512).
Sourcepub fn has_entry(&self, key: &ProviderInterestKey) -> bool
pub fn has_entry(&self, key: &ProviderInterestKey) -> bool
Whether ANY entry exists for the key (live rows or not-yet- swept ones) — the refusal-tombstone GC’s liveness input (SI-3 closure item 6).
Sourcepub fn aggregate(
&self,
key: &ProviderInterestKey,
now: Instant,
) -> Option<Duration>
pub fn aggregate( &self, key: &ProviderInterestKey, now: Instant, ) -> Option<Duration>
Strictest live D for a key — the derived upstream aggregate.
Sourcepub fn local_consumer_interval(
&self,
key: &ProviderInterestKey,
now: Instant,
) -> Option<Duration>
pub fn local_consumer_interval( &self, key: &ProviderInterestKey, now: Instant, ) -> Option<Duration>
The single authoritative LOCAL-consumer demand projection for a branch:
the strictest (minimum) sample interval across this node’s live
node-local rows — the direct DownstreamId::Local and the leased
DownstreamId::LeasedLocal. The shared consumer overlay cell must
re-anchor to THIS aggregate on every mutation, never to the latest
registering/delivering row’s own interval (review L1 follow-up): the two
ownership rows are distinct table slots but feed ONE consumer cell.
None when no live node-local row exists (the branch may still be kept
alive by a peer or leader row, which must not leave a ghost consumer cell).
Sourcepub fn register(
&mut self,
key: &ProviderInterestKey,
downstream: DownstreamId,
requested_sample_interval: Duration,
soft_state_ttl: Duration,
owner_root: AudienceScopeCommitment,
now: Instant,
) -> RegisterOutcome
pub fn register( &mut self, key: &ProviderInterestKey, downstream: DownstreamId, requested_sample_interval: Duration, soft_state_ttl: Duration, owner_root: AudienceScopeCommitment, now: Instant, ) -> RegisterOutcome
Register or refresh one downstream’s interest. Refreshing
re-arms expires_at = now + ttl; each downstream expires
independently.
Sourcepub fn expire(
&mut self,
now: Instant,
) -> Vec<(ProviderInterestKey, UpstreamAction)>
pub fn expire( &mut self, now: Instant, ) -> Vec<(ProviderInterestKey, UpstreamAction)>
Drop expired downstream rows everywhere and report the keys whose upstream aggregate consequently changed. Empty entries (and their cached floors) are removed entirely.
Sourcepub fn remove_downstream(
&mut self,
downstream: DownstreamId,
now: Instant,
) -> Vec<(ProviderInterestKey, UpstreamAction)>
pub fn remove_downstream( &mut self, downstream: DownstreamId, now: Instant, ) -> Vec<(ProviderInterestKey, UpstreamAction)>
Downstream loss (plan §4.7): drop every row a departed peer held; derived aggregates recompute per key.
Sourcepub fn deregister(
&mut self,
interest_digest: &Digest256,
provider: Option<u64>,
downstream: DownstreamId,
now: Instant,
) -> Vec<(ProviderInterestKey, UpstreamAction)>
pub fn deregister( &mut self, interest_digest: &Digest256, provider: Option<u64>, downstream: DownstreamId, now: Instant, ) -> Vec<(ProviderInterestKey, UpstreamAction)>
Explicit withdrawal (plan §4.2 Deregister; SI-2a dispatch):
drop one downstream’s rows for interest_digest — exactly
the (digest, provider) branch when provider is Some, or
that downstream’s rows across every branch of the digest when
None (the whole-interest withdrawal). Reports each touched
key’s upstream consequence exactly as Self::expire does.
Unknown digests and absent rows are a no-op — deregistration
of soft state is idempotent, so a duplicated or crossed
Deregister frame removes nothing twice.
Sourcepub fn on_refusal(
&mut self,
key: &ProviderInterestKey,
minimum_supported: Duration,
now: Instant,
) -> RefusalPartition
pub fn on_refusal( &mut self, key: &ProviderInterestKey, minimum_supported: Duration, now: Instant, ) -> RefusalPartition
Apply a provider refusal sampling_interval_unsupported { M }
(plan §4.4): partition on M, cache M, report the refused
downstreams and the satisfiable aggregate to re-register —
exactly once; a duplicate refusal at the same M is absorbed.
Sourcepub fn commit_advertised(
&mut self,
key: &ProviderInterestKey,
strictest: Duration,
)
pub fn commit_advertised( &mut self, key: &ProviderInterestKey, strictest: Duration, )
SI-3 closure item 2: consume a pending upstream transition
after SUCCESSFULLY sending the re-registration the caller
derived from Self::on_refusal’s Register { strictest }.
Callers that cannot send (no spec cache at this hop) simply
never commit — the next downstream refresh repairs through
register()’s own diff, which commits structurally.
Sourcepub fn remove_branch(&mut self, key: &ProviderInterestKey) -> Vec<DownstreamId>
pub fn remove_branch(&mut self, key: &ProviderInterestKey) -> Vec<DownstreamId>
SI-6.1 (fold-membership reconciliation): drop one branch ENTIRELY — every downstream row and the cached floor — releasing the per-downstream counts. For a provider the fold no longer makes eligible, there is nothing to partition or expire toward: the branch itself is dead. The caller owns the upstream/observation consequences. Returns the rows that were dropped.
Sourcepub fn invalidate_provider_floors(&mut self, provider: u64)
pub fn invalidate_provider_floors(&mut self, provider: u64)
Provider incarnation OR generation change: the floor may have changed with either (a restart reconfigures, a redefinition re-specs), so every cached M for that provider is invalidated (plan §4.4/§4.8). The branch entries themselves survive — the routed key binds neither epoch (v4.1 §3.2).
Sourcepub fn upstream_continuity(
&self,
key: &ProviderInterestKey,
) -> Option<Continuity>
pub fn upstream_continuity( &self, key: &ProviderInterestKey, ) -> Option<Continuity>
The relay’s own upstream continuity for a key (plan §4.3) — read by the delivery layer’s hop rule.
Sourcepub fn set_upstream_continuity(
&mut self,
key: &ProviderInterestKey,
continuity: Continuity,
)
pub fn set_upstream_continuity( &mut self, key: &ProviderInterestKey, continuity: Continuity, )
Update the stored upstream continuity (driven by the relay’s
own ObservationCell for the key).
Sourcepub fn cached_floor(&self, key: &ProviderInterestKey) -> Option<Duration>
pub fn cached_floor(&self, key: &ProviderInterestKey) -> Option<Duration>
The cached provider floor for a key, if any.
Sourcepub fn downstreams(
&self,
key: &ProviderInterestKey,
now: Instant,
) -> Vec<DownstreamId>
pub fn downstreams( &self, key: &ProviderInterestKey, now: Instant, ) -> Vec<DownstreamId>
Live downstream ids for a key (delivery fan-out, SI-0f).
Sourcepub fn downstream_entry(
&self,
key: &ProviderInterestKey,
downstream: DownstreamId,
) -> Option<&DownstreamEntry>
pub fn downstream_entry( &self, key: &ProviderInterestKey, downstream: DownstreamId, ) -> Option<&DownstreamEntry>
One downstream’s live row for a key (delivery scheduling).