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§
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)
Sourcefn stakers_of(&self, validator: ValidatorId) -> Vec<(Vec<u8>, StakeEntry)>
fn stakers_of(&self, validator: ValidatorId) -> Vec<(Vec<u8>, StakeEntry)>
Return all (staker_address, entry) pairs for a given validator.
Sourcefn push_unbonding(&mut self, entry: UnbondingEntry)
fn push_unbonding(&mut self, entry: UnbondingEntry)
Append an entry to the unbonding queue.
Sourcefn drain_mature_unbondings(
&mut self,
current_height: u64,
) -> Vec<UnbondingEntry>
fn drain_mature_unbondings( &mut self, current_height: u64, ) -> Vec<UnbondingEntry>
Remove and return all entries whose completion_height <= current_height.
Sourcefn all_unbondings(&self) -> Vec<UnbondingEntry>
fn all_unbondings(&self) -> Vec<UnbondingEntry>
Return all pending unbonding entries (for slashing).
Sourcefn replace_unbondings(&mut self, entries: Vec<UnbondingEntry>)
fn replace_unbondings(&mut self, entries: Vec<UnbondingEntry>)
Replace the entire unbonding queue (used after slashing adjustments).