#[non_exhaustive]pub struct GetAvailabilityParams {
pub items: Vec<AvailabilityQuery>,
pub redirect_depth: Option<u64>,
}Expand description
Params for dig.getAvailability.
§Construction
Like FetchRangeParams, this type is #[non_exhaustive]: build it with
new plus the with_* setters rather than a struct literal, so a
future additive field is a PATCH for every consumer instead of a semver cascade.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.items: Vec<AvailabilityQuery>The items to check. Capped at 512 per batch (past-cap items are dropped).
redirect_depth: Option<u64>The hop budget already consumed by this ask. Absent means zero — read it
through hops_consumed, never directly.
§What it means for an availability ask
An availability answer is not only this node’s holdings: on a miss it may
name the holders it located, in
AvailabilityAnswer::providers — the same
enrichment a RedirectInfo carries. A responder that cannot answer from
what it holds MAY ask its own peers, so one caller’s question can walk
several hops, and each hop is a node spending someone else’s bandwidth.
This field is what bounds that walk.
It is the SAME budget, counted the SAME way, as
RedirectInfo::redirect_depth and as the redirect_depth that
GetContentParams and FetchRangeParams already echo: the number of
hops ALREADY CONSUMED when this ask arrives, counting UP from zero — never a
remaining allowance counting down. A responder that asks onward sends
hops_consumed() + 1 (saturating at the type maximum), and MUST NOT ask
onward when that would reach the budget it advertises as
RedirectInfo::max_redirects.
Absent reads as a fresh, unhopped ask, so a client written before this field existed is served unchanged.
Implementations§
Source§impl GetAvailabilityParams
impl GetAvailabilityParams
Sourcepub fn new(items: Vec<AvailabilityQuery>) -> Self
pub fn new(items: Vec<AvailabilityQuery>) -> Self
An availability batch for items, asked at hop zero.
Sourcepub fn with_redirect_depth(self, redirect_depth: u64) -> Self
pub fn with_redirect_depth(self, redirect_depth: u64) -> Self
Echo the hop budget already consumed — from a -32008 redirect, or from the
ask this one is being made on behalf of. See
redirect_depth.
Sourcepub fn hops_consumed(&self) -> u64
pub fn hops_consumed(&self) -> u64
The hops already consumed by this ask.
The single home for the “absent means zero” rule. A responder that reached for
redirect_depth.is_some() instead would read every pre-0.8 client’s ask as
budget-free and forward it without bound — the amplification the budget exists
to stop.
Trait Implementations§
Source§impl Clone for GetAvailabilityParams
impl Clone for GetAvailabilityParams
Source§fn clone(&self) -> GetAvailabilityParams
fn clone(&self) -> GetAvailabilityParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more