Skip to main content

TrustStore

Struct TrustStore 

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

The trust store — manages all known peer records

Implementations§

Source§

impl TrustStore

Source

pub fn new() -> Self

Create a new empty trust store

Source

pub async fn verify_or_pin( &self, peer_id: &str, public_key: &[u8], ) -> TrustResult<bool>

Called when we first encounter a peer’s public key (TOFU).

Returns Ok(true) if this is a new peer, Ok(false) if key matches. Returns Err if key has changed for a known peer.

Source

pub async fn add_attestation(&self, attestation: Attestation) -> TrustResult<()>

Record an attestation from a trusted peer about another peer

Source

pub async fn mark_verified( &self, peer_id: &str, verified_key: &[u8], ) -> TrustResult<()>

Upgrade a peer to Verified status (after out-of-band verification)

Source

pub async fn block(&self, peer_id: &str)

Block a peer

Source

pub async fn get(&self, peer_id: &str) -> Option<PeerRecord>

Get trust info for a peer

Source

pub async fn trust_score(&self, peer_id: &str) -> f32

Get trust score (0.0–1.0, or negative for warnings)

Source

pub async fn all_peers(&self) -> Vec<PeerRecord>

List all known peers, sorted by trust score descending

Source

pub async fn set_attester_trust(&self, peer_id: String, score: f32)

Set our trust score for a peer

Source

pub async fn blocked_count(&self) -> usize

Count of blocked peers

Source

pub async fn average_trust_score(&self) -> f32

Average trust score across all known peers

Trait Implementations§

Source§

impl Default for TrustStore

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