Skip to main content

StakeRegistry

Trait StakeRegistry 

Source
pub trait StakeRegistry: Send + Sync {
    // Required methods
    fn get_stake(&self, did: &Did) -> Result<u64, Error>;
    fn set_stake(&mut self, did: &Did, amount: u64) -> Result<(), Error>;
    fn total_stake(&self) -> Result<u64, Error>;

    // Provided methods
    fn has_sufficient_stake(
        &self,
        did: &Did,
        minimum: u64,
    ) -> Result<bool, Error> { ... }
    fn stake_weight(&self, did: &Did) -> Result<f64, Error> { ... }
}
Expand description

Trait for stake registry implementations

A stake registry tracks staked amounts for DIDs and can be used for weighted consensus and reputation systems.

Required Methods§

Source

fn get_stake(&self, did: &Did) -> Result<u64, Error>

Get the staked amount for a DID

Source

fn set_stake(&mut self, did: &Did, amount: u64) -> Result<(), Error>

Set the staked amount for a DID

Source

fn total_stake(&self) -> Result<u64, Error>

Get total staked amount across all DIDs

Provided Methods§

Source

fn has_sufficient_stake(&self, did: &Did, minimum: u64) -> Result<bool, Error>

Check if a DID has sufficient stake

Source

fn stake_weight(&self, did: &Did) -> Result<f64, Error>

Get the stake weight (0.0-1.0) for a DID relative to total

Implementors§