Use balances::TotalIssuance for scaling between votes and balances (#… (#2364)

* Use balances::TotalIssuance for scaling between votes and balances (#2361)

* Use total issuance to convert between votes and balances

* Remove cruft

* Bump runtime version
This commit is contained in:
Gavin Wood
2019-04-24 12:51:46 +02:00
committed by GitHub
parent babe638be7
commit 382caca947
2 changed files with 17 additions and 33 deletions
@@ -150,35 +150,6 @@ impl<A, B: Default> Convert<A, B> for () {
fn convert(_: A) -> B { Default::default() }
}
/// A structure that converts the currency type into a lossy u64
/// And back from u128
pub struct CurrencyToVoteHandler;
impl Convert<u128, u64> for CurrencyToVoteHandler {
fn convert(x: u128) -> u64 {
if x >> 96 == 0 {
// Remove dust; divide by 2^32
(x >> 32) as u64
} else {
u64::max_value()
}
}
}
impl Convert<u128, u128> for CurrencyToVoteHandler {
fn convert(x: u128) -> u128 {
// if it practically fits in u64
if x >> 64 == 0 {
// Add zero dust; multiply by 2^32
x << 32
}
else {
// 0000_0000_FFFF_FFFF_FFFF_FFFF_0000_0000
(u64::max_value() << 32) as u128
}
}
}
/// A structure that performs identity conversion.
pub struct Identity;
impl<T> Convert<T, T> for Identity {