pub trait CurrencyToVote<B> {
// Required methods
fn to_vote(value: B, issuance: B) -> u64;
fn to_currency(value: u128, issuance: B) -> B;
fn will_downscale(issuance: B) -> Option<bool>;
}
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§
Sourcefn to_currency(value: u128, issuance: B) -> B
fn to_currency(value: u128, issuance: B) -> B
Convert u128 to balance.
Sourcefn will_downscale(issuance: B) -> Option<bool>
fn will_downscale(issuance: B) -> Option<bool>
Send a signal whether you are going to downscale the B
when converting to u64
given the
current issuance.
This is useful for automated checks in place to signal maintainers that the total issuance has reached a point where downscaling will happen.
None
means we don’t know. Some(_)
means we know with certainty.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.