Skip to content

Commit

Permalink
fix: bug with ensure! parser
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier committed Nov 25, 2019
1 parent 8619dfc commit 920b338
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions srml/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern crate test;
pub mod inflation;

use codec::{Decode, Encode, HasCompact};
use rstd::{borrow::ToOwned, convert::TryInto, prelude::*, result};
use rstd::{borrow::ToOwned, prelude::*, result};
use session::{historical::OnSessionEnding, SelectInitialValidators};
use sr_primitives::{
traits::{CheckedSub, Convert, One, SaturatedConversion, Saturating, StaticLookup, Zero},
Expand Down Expand Up @@ -540,9 +540,17 @@ decl_module! {
..
} = &mut ledger;

// due to the macro parser, we've to add a bracket
// actually, this's totally wrong:
// `a as u32 + b as u32 < c`
// workaround:
// 1. `(a as u32 + b as u32) < c`
// 2. `let c_ = a as u32 + b as u32; c_ < c`
ensure!(
ring_staking_lock.unbondings.len() + kton_staking_lock.unbondings.len() < MAX_UNLOCKING_CHUNKS.try_into().unwrap(),
"can not schedule more unlock chunks"
(ring_staking_lock.unbondings.len() as u32 + kton_staking_lock.unbondings.len() as u32)
<
MAX_UNLOCKING_CHUNKS,
"can not schedule more unlock chunks",
);

let at = <timestamp::Module<T>>::now().saturated_into::<TimeStamp>() + T::BondingDuration::get();
Expand Down

0 comments on commit 920b338

Please sign in to comment.