[][src]Struct casperlabs_proof_of_stake::Stakes

pub struct Stakes(pub BTreeMap<PublicKey, U512>);

The stakes map, assigning the staked amount of motes to each bonded validator.

Methods

impl Stakes[src]

pub fn new(map: BTreeMap<PublicKey, U512>) -> Stakes[src]

pub fn iter(&self) -> Iter<PublicKey, U512>[src]

pub fn values(&self) -> Values<PublicKey, U512>[src]

pub fn strings(&self) -> impl Iterator<Item = String> + '_[src]

pub fn total_bonds(&self) -> U512[src]

pub fn unbond(
    &mut self,
    validator: &PublicKey,
    maybe_amount: Option<U512>
) -> Result<U512>
[src]

If maybe_amount is None, removes all the validator's stakes, otherwise subtracts the given amount. If the stakes are lower than the specified amount, it also subtracts all the stakes.

Returns the amount that was actually subtracted from the stakes, or an error if

  • unbonding the specified amount is not allowed,
  • tries to unbond last validator,
  • validator was not bonded.

pub fn bond(&mut self, validator: &PublicKey, amount: U512)[src]

Adds amount to the validator's stakes.

pub fn validate_bonding(
    &self,
    validator: &PublicKey,
    amount: U512
) -> Result<()>
[src]

Returns an error if bonding the specified amount is not allowed.

Trait Implementations

impl Clone for Stakes[src]

impl Debug for Stakes[src]

impl PartialEq<Stakes> for Stakes[src]

impl StructuralPartialEq for Stakes[src]

Auto Trait Implementations

impl Send for Stakes

impl Sync for Stakes

impl Unpin for Stakes

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.