Trait sp_staking::currency_to_vote::CurrencyToVote

source ·
pub trait CurrencyToVote<B> {
    // Required methods
    fn to_vote(value: B, issuance: B) -> u64;
    fn to_currency(value: u128, issuance: B) -> B;
}
Expand description

A trait similar to Convert to convert values from B an abstract balance type into u64 and back from u128. (This conversion is used in election and other places where complex calculation over balance type is needed)

Total issuance of the currency is passed in, but an implementation of this trait may or may not use it.

§WARNING

the total issuance being passed in implies that the implementation must be aware of the fact that its values can affect the outcome. This implies that if the vote value is dependent on the total issuance, it should never ber written to storage for later re-use.

Required Methods§

source

fn to_vote(value: B, issuance: B) -> u64

Convert balance to u64.

source

fn to_currency(value: u128, issuance: B) -> B

Convert u128 to balance.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<B: UniqueSaturatedInto<u64> + UniqueSaturatedFrom<u128>> CurrencyToVote<B> for ()

source§

fn to_currency(value: u128, issuance: B) -> B

Convert u128 to balance.

source§

fn to_vote(value: B, issuance: B) -> u64

Implementors§