pub struct ProviderReputationStore { /* private fields */ }Expand description
Local provider reputation database.
Implementations§
Source§impl ProviderReputationStore
impl ProviderReputationStore
pub fn new(config: ReputationConfig) -> Self
Sourcepub fn with_database(
database: IndexingDatabase,
config: ReputationConfig,
) -> Result<Self>
pub fn with_database( database: IndexingDatabase, config: ReputationConfig, ) -> Result<Self>
Create a store backed by an indexing database.
Reputations and signal sequences are hydrated from the database on construction. Mutations are persisted through the database.
§Errors
Returns an error if the database cannot be read.
pub fn with_policy(config: ReputationConfig, policy: TrustPolicy) -> Self
pub const fn config(&self) -> &ReputationConfig
pub fn set_policy(&mut self, policy: TrustPolicy)
Sourcepub const fn set_reporter(&mut self, reporter: PublicKey)
pub const fn set_reporter(&mut self, reporter: PublicKey)
Configure the reporter identity used for reputation transitions.
Sourcepub fn trust_reporter(&mut self, reporter: &PublicKey) -> Result<()>
pub fn trust_reporter(&mut self, reporter: &PublicKey) -> Result<()>
§Errors
Returns an error when the reporter identity is not a valid Ed25519 key.
pub fn reputation(&self, provider: PublicKey) -> ProviderReputation
pub fn score(&self, provider: PublicKey, now: u64) -> f64
pub fn record_fetch_result( &mut self, provider: PublicKey, success: bool, kind: FetchFailureKind, now: u64, )
pub fn record_success(&mut self, provider: PublicKey, now: u64)
pub fn record_failure( &mut self, provider: PublicKey, kind: FetchFailureKind, now: u64, )
pub fn is_banned(&self, provider: PublicKey, now: u64) -> bool
pub fn auto_ban_until(&self, provider: PublicKey) -> Option<u64>
pub fn auto_ban_count(&self, provider: PublicKey) -> u32
Sourcepub fn rejoin(&mut self, provider: PublicKey, now: u64) -> bool
pub fn rejoin(&mut self, provider: PublicKey, now: u64) -> bool
Clear the active timeout while retaining its backoff history.
pub fn should_skip_provider( &self, provider: PublicKey, now: u64, threshold: f64, ) -> bool
Sourcepub fn rank_providers(&self, now: u64, hash: Hash) -> Vec<PublicKey>
pub fn rank_providers(&self, now: u64, hash: Hash) -> Vec<PublicKey>
Return all known providers, ranked by score and then hash distance.
pub fn rank_provider_list( &self, now: u64, hash: Hash, providers: &[PublicKey], ) -> Vec<PublicKey>
pub fn purge_stale(&mut self, now: u64, ttl: Duration)
Sourcepub fn queue_trust_signal(
&mut self,
signal: ProviderTrustSignal,
) -> Result<bool>
pub fn queue_trust_signal( &mut self, signal: ProviderTrustSignal, ) -> Result<bool>
Queue one observation, coalescing identical observations in the batch.
§Errors
Returns an error when the signal structure is invalid.
pub fn pending_trust_signals(&self) -> &[ProviderTrustSignal]
pub fn take_pending_trust_signals(&mut self) -> Vec<ProviderTrustSignal>
pub fn set_max_signal_batch(&mut self, max_signal_batch: usize)
Sourcepub fn ingest_trust_signal(
&mut self,
signal: ProviderTrustSignal,
) -> Result<bool>
pub fn ingest_trust_signal( &mut self, signal: ProviderTrustSignal, ) -> Result<bool>
Accept a signed observation from a locally trusted reporter.
§Errors
Returns an error when the signal is malformed, expired, or unsigned.
Sourcepub async fn publish_signal(
&self,
gossip: &GossipService,
sender: &GossipSender,
signal: &ProviderTrustSignal,
) -> Result<()>
pub async fn publish_signal( &self, gossip: &GossipService, sender: &GossipSender, signal: &ProviderTrustSignal, ) -> Result<()>
Publish a signed signal to the provider-trust stream.
§Errors
Returns an error when the signal is invalid or gossip rejects the publication.
Sourcepub async fn subscribe_trust_stream(
&self,
gossip: &GossipService,
bootstrap: Vec<PublicKey>,
) -> Result<GossipTopic>
pub async fn subscribe_trust_stream( &self, gossip: &GossipService, bootstrap: Vec<PublicKey>, ) -> Result<GossipTopic>
Subscribe to the provider-trust stream.
§Errors
Returns an error when the gossip subscription cannot be created.
Trait Implementations§
Source§impl Clone for ProviderReputationStore
impl Clone for ProviderReputationStore
Source§fn clone(&self) -> ProviderReputationStore
fn clone(&self) -> ProviderReputationStore
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 ProviderReputationStore
impl Debug for ProviderReputationStore
Auto Trait Implementations§
impl Freeze for ProviderReputationStore
impl RefUnwindSafe for ProviderReputationStore
impl Send for ProviderReputationStore
impl Sync for ProviderReputationStore
impl Unpin for ProviderReputationStore
impl UnsafeUnpin for ProviderReputationStore
impl UnwindSafe for ProviderReputationStore
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