-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Remove As trait bound from Currency::Balance #2205
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -894,8 +894,10 @@ impl<T: Trait> Module<T> { | |
| Self::reward_validator(v, reward); | ||
| } | ||
| Self::deposit_event(RawEvent::Reward(reward)); | ||
| let total_minted = reward * <BalanceOf<T> as As<usize>>::sa(validators.len()); | ||
| let total_rewarded_stake = Self::slot_stake() * <BalanceOf<T> as As<usize>>::sa(validators.len()); | ||
| let len = validators.len() as u64; // validators length can never overflow u64 | ||
| let len = BalanceOf::<T>::sa(len); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have written this in one line but whatever |
||
| let total_minted = reward * len; | ||
| let total_rewarded_stake = Self::slot_stake() * len; | ||
| T::OnRewardMinted::on_dilution(total_minted, total_rewarded_stake); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
| use crate::rstd::result; | ||
| use crate::codec::{Codec, Encode, Decode}; | ||
| use crate::runtime_primitives::traits::{ | ||
| MaybeSerializeDebug, SimpleArithmetic, As | ||
| MaybeSerializeDebug, SimpleArithmetic | ||
| }; | ||
|
|
||
| /// The account with the given id was killed. | ||
|
|
@@ -195,7 +195,7 @@ pub enum SignedImbalance<B, P: Imbalance<B>>{ | |
| impl< | ||
| P: Imbalance<B, Opposite=N>, | ||
| N: Imbalance<B, Opposite=P>, | ||
| B: SimpleArithmetic + As<usize> + As<u64> + Codec + Copy + MaybeSerializeDebug + Default, | ||
| B: SimpleArithmetic + Codec + Copy + MaybeSerializeDebug + Default, | ||
| > SignedImbalance<B, P> { | ||
| pub fn zero() -> Self { | ||
| SignedImbalance::Positive(P::zero()) | ||
|
|
@@ -230,7 +230,7 @@ impl< | |
| /// Abstraction over a fungible assets system. | ||
| pub trait Currency<AccountId> { | ||
| /// The balance of an account. | ||
| type Balance: SimpleArithmetic + As<usize> + As<u64> + Codec + Copy + MaybeSerializeDebug + Default; | ||
| type Balance: SimpleArithmetic + Codec + Copy + MaybeSerializeDebug + Default; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems to me that only having but SimpleArithmetic bouds
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also agree with the concept of Question though:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I tried to say in my second paragraph
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I went blind for a sec apparently. @xlc Did you ever test to see if this PR, with its current state, actually solve your initial problem (storing some kind of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. As other pointed out, |
||
|
|
||
| /// The opaque token type for an imbalance. This is returned by unbalanced operations | ||
| /// and must be dealt with. It may be dropped but cannot be cloned. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.