pub struct ProviderLeaseTracker { /* private fields */ }Expand description
In-memory tracker for signed provider leases and local observations.
Implementations§
Source§impl ProviderLeaseTracker
impl ProviderLeaseTracker
Sourcepub fn with_max_failures_per_provider(max_failures_per_provider: usize) -> Self
pub fn with_max_failures_per_provider(max_failures_per_provider: usize) -> Self
Create an empty tracker with a bounded failure history.
Sourcepub const fn max_failures_per_provider(&self) -> usize
pub const fn max_failures_per_provider(&self) -> usize
Return the failure-detail cap for each (hash, provider) pair.
Sourcepub fn set_max_failures_per_provider(
&mut self,
max_failures_per_provider: usize,
)
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.
Sourcepub fn track(&mut self, lease: ProviderLease) -> Result<LeaseUpdate>
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.
Sourcepub fn track_at(
&mut self,
lease: ProviderLease,
now: u64,
) -> Result<LeaseUpdate>
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.
Sourcepub fn record_lease(&mut self, lease: ProviderLease) -> Result<LeaseUpdate>
pub fn record_lease(&mut self, lease: ProviderLease) -> Result<LeaseUpdate>
Sourcepub fn add_lease(&mut self, lease: ProviderLease) -> Result<LeaseUpdate>
pub fn add_lease(&mut self, lease: ProviderLease) -> Result<LeaseUpdate>
Sourcepub fn invalidate_lease(&mut self, hash: Hash, provider: PublicKey) -> bool
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.
Sourcepub fn invalidate_lease_at(
&mut self,
hash: Hash,
provider: PublicKey,
now: u64,
) -> bool
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.
Sourcepub fn is_banned(&self, provider: PublicKey, hash: &Hash, now: u64) -> bool
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.
Sourcepub fn ban_provider(
&mut self,
provider: PublicKey,
scope: Option<Hash>,
reason: impl Into<String>,
source: BanSource,
duration: Option<Duration>,
now: u64,
) -> BanRecord
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.
Sourcepub fn apply_ban_record(&mut self, record: BanRecord)
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.
Sourcepub fn unban_provider(
&mut self,
provider: PublicKey,
scope: Option<Hash>,
) -> bool
pub fn unban_provider( &mut self, provider: PublicKey, scope: Option<Hash>, ) -> bool
Remove a global or hash-scoped ban.
Sourcepub fn banned_providers(&self, hash: &Hash, now: u64) -> Vec<PublicKey>
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.
Sourcepub fn ban_records(&self, hash: &Hash, now: u64) -> Vec<BanRecord>
pub fn ban_records(&self, hash: &Hash, now: u64) -> Vec<BanRecord>
Return active ban records applying to a blob.
Sourcepub fn retroactive_invalidate(
&mut self,
hash: Hash,
successful_provider: PublicKey,
now: u64,
) -> Vec<PublicKey>
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.
Sourcepub fn record_failure(
&mut self,
hash: Hash,
provider: PublicKey,
failure: FetchFailure,
)
pub fn record_failure( &mut self, hash: Hash, provider: PublicKey, failure: FetchFailure, )
Record a provider failure using the current epoch time.
Sourcepub fn record_failure_at(
&mut self,
hash: Hash,
provider: PublicKey,
failure: FetchFailure,
now: u64,
)
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.
Sourcepub fn failure_record(
&self,
hash: &Hash,
provider: &PublicKey,
) -> Option<&FailureRecord>
pub fn failure_record( &self, hash: &Hash, provider: &PublicKey, ) -> Option<&FailureRecord>
Return the bounded failure details for a provider and blob.
Sourcepub fn failure_count(&self, hash: &Hash, provider: &PublicKey) -> usize
pub fn failure_count(&self, hash: &Hash, provider: &PublicKey) -> usize
Return the aggregate failure count for a provider and blob.
Sourcepub fn consecutive_failures(&self, hash: &Hash, provider: &PublicKey) -> u32
pub fn consecutive_failures(&self, hash: &Hash, provider: &PublicKey) -> u32
Return the current consecutive definitive-failure count.
Sourcepub fn is_definitively_failed(&self, hash: &Hash, provider: &PublicKey) -> bool
pub fn is_definitively_failed(&self, hash: &Hash, provider: &PublicKey) -> bool
Return whether a provider has crossed the definitive-failure threshold.
Sourcepub fn clear_failures_for_provider(&mut self, hash: &Hash, provider: &PublicKey)
pub fn clear_failures_for_provider(&mut self, hash: &Hash, provider: &PublicKey)
Clear all failure history for a provider after a successful fetch.
Sourcepub fn purge_stale_failures(&mut self, now: u64, ttl: Duration)
pub fn purge_stale_failures(&mut self, now: u64, ttl: Duration)
Remove failure records whose last observation is outside ttl.
Sourcepub fn observe_provider(&mut self, hash: Hash, provider: PublicKey)
pub fn observe_provider(&mut self, hash: Hash, provider: PublicKey)
Record that a provider was observed serving a blob locally.
Sourcepub fn observe_provider_at(
&mut self,
hash: Hash,
provider: PublicKey,
observed_at: u64,
)
pub fn observe_provider_at( &mut self, hash: Hash, provider: PublicKey, observed_at: u64, )
Record a provider observation at an explicit time.
Sourcepub fn leases(&self, hash: &Hash) -> Vec<ProviderLease>
pub fn leases(&self, hash: &Hash) -> Vec<ProviderLease>
Return active leases for a blob.
Sourcepub fn leases_at(&self, hash: &Hash, now: u64) -> Vec<ProviderLease>
pub fn leases_at(&self, hash: &Hash, now: u64) -> Vec<ProviderLease>
Return active leases for a blob at an explicit time.
Sourcepub fn providers(&self, hash: &Hash) -> Vec<PublicKey>
pub fn providers(&self, hash: &Hash) -> Vec<PublicKey>
Return active provider identities for a blob.
Sourcepub fn verified_count(&self, hash: &Hash) -> usize
pub fn verified_count(&self, hash: &Hash) -> usize
Return the number of active, previously verified leases.
Sourcepub fn list_providers(&self) -> Vec<PublicKey>
pub fn list_providers(&self) -> Vec<PublicKey>
Return all providers that have an active lease for any blob.
Sourcepub fn blobs_for_provider(&self, provider: &PublicKey) -> Vec<Hash>
pub fn blobs_for_provider(&self, provider: &PublicKey) -> Vec<Hash>
Return all blob hashes for which the given provider has an active lease.
Sourcepub fn health(
&self,
hash: &Hash,
observation_ttl: Duration,
) -> AvailabilityHealth
pub fn health( &self, hash: &Hash, observation_ttl: Duration, ) -> AvailabilityHealth
Build a verified-vs-local availability report.
Trait Implementations§
Source§impl Clone for ProviderLeaseTracker
impl Clone for ProviderLeaseTracker
Source§fn clone(&self) -> ProviderLeaseTracker
fn clone(&self) -> ProviderLeaseTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProviderLeaseTracker
impl Debug for ProviderLeaseTracker
Auto Trait Implementations§
impl Freeze for ProviderLeaseTracker
impl RefUnwindSafe for ProviderLeaseTracker
impl Send for ProviderLeaseTracker
impl Sync for ProviderLeaseTracker
impl Unpin for ProviderLeaseTracker
impl UnsafeUnpin for ProviderLeaseTracker
impl UnwindSafe for ProviderLeaseTracker
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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