mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Proposal: Defensive trait for infallible frame operations (#10626)
* add a blueprint of how defensive traits could look like * add something for arithmetic as well * add some use cases in different pallets * some build fixing * Some new stuff and examples * Fix deadly bug * add more doc. * undo faulty change to assets pallet * Update frame/support/src/traits/misc.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * some review comments * remove draft comment * Fix ident test * Fix proxy tests as well * a few new ideas * Fix build * Fix doc Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -25,7 +25,7 @@ use crate::{
|
||||
use codec::{Decode, Encode, HasCompact};
|
||||
use frame_support::{
|
||||
storage::bounded_btree_map::BoundedBTreeMap,
|
||||
traits::{Currency, Get, OnUnbalanced, ReservableCurrency},
|
||||
traits::{defensive_prelude::*, Currency, Get, OnUnbalanced, ReservableCurrency},
|
||||
};
|
||||
use sp_arithmetic::traits::SaturatedConversion;
|
||||
use sp_npos_elections::{is_score_better, ElectionScore, NposSolution};
|
||||
@@ -365,7 +365,7 @@ impl<T: Config> Pallet<T> {
|
||||
let active_voters = raw_solution.solution.voter_count() as u32;
|
||||
let feasibility_weight = {
|
||||
// defensive only: at the end of signed phase, snapshot will exits.
|
||||
let desired_targets = Self::desired_targets().unwrap_or_default();
|
||||
let desired_targets = Self::desired_targets().defensive_unwrap_or_default();
|
||||
T::WeightInfo::feasibility_check(voters, targets, active_voters, desired_targets)
|
||||
};
|
||||
// the feasibility check itself has some weight
|
||||
|
||||
Reference in New Issue
Block a user