Skip to main content

InterestTable

Struct InterestTable 

Source
pub struct InterestTable { /* private fields */ }
Expand description

The per-hop interest table (plan §4.3).

Implementations§

Source§

impl InterestTable

Source

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).

Source

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).

Source

pub fn aggregate( &self, key: &ProviderInterestKey, now: Instant, ) -> Option<Duration>

Strictest live D for a key — the derived upstream aggregate.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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).

Source

pub fn cached_floor(&self, key: &ProviderInterestKey) -> Option<Duration>

The cached provider floor for a key, if any.

Source

pub fn downstreams( &self, key: &ProviderInterestKey, now: Instant, ) -> Vec<DownstreamId>

Live downstream ids for a key (delivery fan-out, SI-0f).

Source

pub fn downstream_entry( &self, key: &ProviderInterestKey, downstream: DownstreamId, ) -> Option<&DownstreamEntry>

One downstream’s live row for a key (delivery scheduling).

Source

pub fn len(&self) -> usize

Number of keys with any (possibly expired-but-unswept) rows.

Source

pub fn is_empty(&self) -> bool

Whether the table holds no interests at all — the zero-idle- cost criterion (plan §8).

Trait Implementations§

Source§

impl Debug for InterestTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more