Skip to main content

StakingStore

Trait StakingStore 

Source
pub trait StakingStore {
    // Required methods
    fn get_validator(&self, id: ValidatorId) -> Option<ValidatorState>;
    fn set_validator(&mut self, id: ValidatorId, state: ValidatorState);
    fn remove_validator(&mut self, id: ValidatorId);
    fn all_validator_ids(&self) -> Vec<ValidatorId>;
    fn get_stake(
        &self,
        staker: &[u8],
        validator: ValidatorId,
    ) -> Option<StakeEntry>;
    fn set_stake(
        &mut self,
        staker: &[u8],
        validator: ValidatorId,
        entry: StakeEntry,
    );
    fn remove_stake(&mut self, staker: &[u8], validator: ValidatorId);
    fn stakers_of(&self, validator: ValidatorId) -> Vec<(Vec<u8>, StakeEntry)>;
    fn push_unbonding(&mut self, entry: UnbondingEntry);
    fn drain_mature_unbondings(
        &mut self,
        current_height: u64,
    ) -> Vec<UnbondingEntry>;
    fn all_unbondings(&self) -> Vec<UnbondingEntry>;
    fn replace_unbondings(&mut self, entries: Vec<UnbondingEntry>);
}
Expand description

Abstract storage backend for staking state.

Implement this trait to plug in any persistence layer (in-memory, vsdb, RocksDB, etc.). The staking manager operates entirely through this interface and never assumes a specific storage backend.

Required Methods§

Source

fn get_validator(&self, id: ValidatorId) -> Option<ValidatorState>

Source

fn set_validator(&mut self, id: ValidatorId, state: ValidatorState)

Source

fn remove_validator(&mut self, id: ValidatorId)

Source

fn all_validator_ids(&self) -> Vec<ValidatorId>

Source

fn get_stake(&self, staker: &[u8], validator: ValidatorId) -> Option<StakeEntry>

Source

fn set_stake( &mut self, staker: &[u8], validator: ValidatorId, entry: StakeEntry, )

Source

fn remove_stake(&mut self, staker: &[u8], validator: ValidatorId)

Source

fn stakers_of(&self, validator: ValidatorId) -> Vec<(Vec<u8>, StakeEntry)>

Return all (staker_address, entry) pairs for a given validator.

Source

fn push_unbonding(&mut self, entry: UnbondingEntry)

Append an entry to the unbonding queue.

Source

fn drain_mature_unbondings( &mut self, current_height: u64, ) -> Vec<UnbondingEntry>

Remove and return all entries whose completion_height <= current_height.

Source

fn all_unbondings(&self) -> Vec<UnbondingEntry>

Return all pending unbonding entries (for slashing).

Source

fn replace_unbondings(&mut self, entries: Vec<UnbondingEntry>)

Replace the entire unbonding queue (used after slashing adjustments).

Implementors§