pub struct StakingState {
pub validators: BTreeMap<Vec<u8>, ValidatorStake>,
pub current_height: u64,
pub treasury_account_id: Option<[u8; 32]>,
}Fields§
§validators: BTreeMap<Vec<u8>, ValidatorStake>§current_height: u64§treasury_account_id: Option<[u8; 32]>Treasury account that receives slashed tokens when no other validators are eligible.
Implementations§
Source§impl StakingState
impl StakingState
pub fn new() -> Self
pub fn stake( &mut self, validator_pubkey: Vec<u8>, amount: u64, ) -> Result<(), String>
pub fn unstake( &mut self, validator_pubkey: &[u8], amount: u64, ) -> Result<(), String>
pub fn withdraw(&mut self, validator_pubkey: &[u8]) -> Result<u64, String>
pub fn get_active_validators(&self) -> HashMap<Vec<u8>, u64>
pub fn advance_height(&mut self)
pub fn compute_slash_outcome( &self, validator_pubkey: &[u8], reason: SlashReason, evidence: Option<DoubleSignEvidence>, ) -> Result<SlashOutcome, String>
pub fn apply_slash_outcome( &mut self, validator_pubkey: &[u8], reason: SlashReason, outcome: &SlashOutcome, evidence: Option<DoubleSignEvidence>, ) -> Result<(), String>
pub fn slash_validator( &mut self, validator_pubkey: &[u8], reason: SlashReason, evidence: Option<DoubleSignEvidence>, ) -> Result<SlashOutcome, String>
Sourcepub fn slash_for_oracle_lie(
&mut self,
validator_pubkey: &[u8],
) -> Result<u64, String>
pub fn slash_for_oracle_lie( &mut self, validator_pubkey: &[u8], ) -> Result<u64, String>
Slash a validator who committed to an oracle request then revealed fabricated data. Cryptographic proof: the stored commit_hash != blake3(validator_pk || request_id || revealed_body). This is called from apply_diff when a reveal fails hash verification.
Sourcepub fn slash_silent_oracle_validators(
&mut self,
request_id: [u8; 32],
committed_validators: &[Vec<u8>],
revealed_validators: &[Vec<u8>],
) -> Vec<(Vec<u8>, u64)>
pub fn slash_silent_oracle_validators( &mut self, request_id: [u8; 32], committed_validators: &[Vec<u8>], revealed_validators: &[Vec<u8>], ) -> Vec<(Vec<u8>, u64)>
Slash every validator that committed to request_id but never revealed within
ORACLE_REVEAL_DEADLINE_BLOCKS blocks. Called from apply_diff when a request expires.
Returns a Vec of (validator_pubkey, amount_slashed).
pub fn unjail(&mut self, validator_pubkey: &[u8]) -> Result<(), String>
Trait Implementations§
Source§impl Clone for StakingState
impl Clone for StakingState
Source§fn clone(&self) -> StakingState
fn clone(&self) -> StakingState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StakingState
impl Debug for StakingState
Source§impl<'de> Deserialize<'de> for StakingState
impl<'de> Deserialize<'de> for StakingState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for StakingState
impl RefUnwindSafe for StakingState
impl Send for StakingState
impl Sync for StakingState
impl Unpin for StakingState
impl UnsafeUnpin for StakingState
impl UnwindSafe for StakingState
Blanket Implementations§
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
Mutably borrows from an owned value. Read more