Skip to main content

ProviderLeaseTracker

Struct ProviderLeaseTracker 

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

In-memory tracker for signed provider leases and local observations.

Implementations§

Source§

impl ProviderLeaseTracker

Source

pub fn with_max_failures_per_provider(max_failures_per_provider: usize) -> Self

Create an empty tracker with a bounded failure history.

Source

pub const fn max_failures_per_provider(&self) -> usize

Return the failure-detail cap for each (hash, provider) pair.

Source

pub fn set_max_failures_per_provider( &mut self, max_failures_per_provider: usize, )

Set the failure-detail cap and evict oldest details if necessary.

Source

pub fn track(&mut self, lease: ProviderLease) -> Result<LeaseUpdate>

Track an active, signed lease using the current time.

§Errors

Returns an error if the lease signature or expiry is invalid.

Source

pub fn track_at( &mut self, lease: ProviderLease, now: u64, ) -> Result<LeaseUpdate>

Track an active, signed lease at an explicit time.

Older sequence numbers from the same provider are ignored. A new sequence replaces the provider’s previous lease for this blob.

§Errors

Returns an error if the lease signature or expiry is invalid.

Source

pub fn record_lease(&mut self, lease: ProviderLease) -> Result<LeaseUpdate>

Alias for Self::track.

§Errors

Returns an error if the lease signature or expiry is invalid.

Source

pub fn add_lease(&mut self, lease: ProviderLease) -> Result<LeaseUpdate>

Alias for Self::track.

§Errors

Returns an error if the lease signature or expiry is invalid.

Source

pub fn invalidate_lease(&mut self, hash: Hash, provider: PublicKey) -> bool

Remove a provider’s lease for a blob and record an automated, hash-scoped ban.

Source

pub fn invalidate_lease_at( &mut self, hash: Hash, provider: PublicKey, now: u64, ) -> bool

Remove a provider’s lease and record an automated ban at an explicit time.

Source

pub fn is_banned(&self, provider: PublicKey, hash: &Hash, now: u64) -> bool

Return whether a provider is covered by an active global or hash-scoped ban.

Source

pub fn ban_provider( &mut self, provider: PublicKey, scope: Option<Hash>, reason: impl Into<String>, source: BanSource, duration: Option<Duration>, now: u64, ) -> BanRecord

Add or update a global or hash-scoped provider ban.

Source

pub fn apply_ban_record(&mut self, record: BanRecord)

Apply a persisted ban record to in-memory state.

Used when hydrating bans from the database on construction.

Source

pub fn unban_provider( &mut self, provider: PublicKey, scope: Option<Hash>, ) -> bool

Remove a global or hash-scoped ban.

Source

pub fn banned_providers(&self, hash: &Hash, now: u64) -> Vec<PublicKey>

Return active provider identities covered by global and hash-scoped bans for a blob.

Source

pub fn ban_records(&self, hash: &Hash, now: u64) -> Vec<BanRecord>

Return active ban records applying to a blob.

Source

pub fn retroactive_invalidate( &mut self, hash: Hash, successful_provider: PublicKey, now: u64, ) -> Vec<PublicKey>

Invalidate all providers with definitive failures for a blob except the provider that successfully supplied it.

Source

pub fn record_failure( &mut self, hash: Hash, provider: PublicKey, failure: FetchFailure, )

Record a provider failure using the current epoch time.

Source

pub fn record_failure_at( &mut self, hash: Hash, provider: PublicKey, failure: FetchFailure, now: u64, )

Record a provider failure at an explicit time.

Failure details are capped per provider, while aggregate counts remain available through Self::failure_count.

Source

pub fn failure_record( &self, hash: &Hash, provider: &PublicKey, ) -> Option<&FailureRecord>

Return the bounded failure details for a provider and blob.

Source

pub fn failure_count(&self, hash: &Hash, provider: &PublicKey) -> usize

Return the aggregate failure count for a provider and blob.

Source

pub fn consecutive_failures(&self, hash: &Hash, provider: &PublicKey) -> u32

Return the current consecutive definitive-failure count.

Source

pub fn is_definitively_failed(&self, hash: &Hash, provider: &PublicKey) -> bool

Return whether a provider has crossed the definitive-failure threshold.

Source

pub fn clear_failures_for_provider(&mut self, hash: &Hash, provider: &PublicKey)

Clear all failure history for a provider after a successful fetch.

Source

pub fn purge_stale_failures(&mut self, now: u64, ttl: Duration)

Remove failure records whose last observation is outside ttl.

Source

pub fn observe_provider(&mut self, hash: Hash, provider: PublicKey)

Record that a provider was observed serving a blob locally.

Source

pub fn observe_provider_at( &mut self, hash: Hash, provider: PublicKey, observed_at: u64, )

Record a provider observation at an explicit time.

Source

pub fn leases(&self, hash: &Hash) -> Vec<ProviderLease>

Return active leases for a blob.

Source

pub fn leases_at(&self, hash: &Hash, now: u64) -> Vec<ProviderLease>

Return active leases for a blob at an explicit time.

Source

pub fn providers(&self, hash: &Hash) -> Vec<PublicKey>

Return active provider identities for a blob.

Source

pub fn verified_count(&self, hash: &Hash) -> usize

Return the number of active, previously verified leases.

Source

pub fn list_providers(&self) -> Vec<PublicKey>

Return all providers that have an active lease for any blob.

Source

pub fn blobs_for_provider(&self, provider: &PublicKey) -> Vec<Hash>

Return all blob hashes for which the given provider has an active lease.

Source

pub fn health( &self, hash: &Hash, observation_ttl: Duration, ) -> AvailabilityHealth

Build a verified-vs-local availability report.

Source

pub fn health_at( &self, hash: &Hash, now: u64, observation_ttl: Duration, ) -> AvailabilityHealth

Build an availability report at an explicit time.

Source

pub fn purge(&mut self, now: u64, observation_ttl: Duration)

Remove expired leases and stale local observations.

Trait Implementations§

Source§

impl Clone for ProviderLeaseTracker

Source§

fn clone(&self) -> ProviderLeaseTracker

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProviderLeaseTracker

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ProviderLeaseTracker

Source§

fn default() -> Self

Returns the “default value” for a type. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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