File tree Expand file tree Collapse file tree 4 files changed +9
-11
lines changed
substrate/frame/staking/src Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -422,10 +422,6 @@ impl ExtBuilder {
422422 . build_storage :: < Test > ( )
423423 . unwrap ( ) ;
424424
425- sp_state_machine:: BasicExternalities :: execute_with_storage ( & mut storage, || {
426- Staking :: set_whitelist ( Origin :: root ( ) , ( 0 ..100 ) . collect ( ) ) . unwrap ( ) ;
427- } ) ;
428-
429425 let _ = pallet_balances:: GenesisConfig :: < Test > {
430426 balances : vec ! [
431427 ( 1 , 10 * self . balance_factor) ,
Original file line number Diff line number Diff line change @@ -444,7 +444,11 @@ impl<T: Config> Pallet<T> {
444444
445445 let whitelist = Self :: candidate_whitelist ( ) ;
446446 let to_remove: Vec < _ > = Validators :: < T > :: iter_keys ( )
447- . filter ( |validator| !whitelist. contains ( & validator) )
447+ . filter ( |validator| {
448+ whitelist
449+ . as_ref ( )
450+ . map_or ( false , |set| !set. contains ( & validator) )
451+ } )
448452 . collect ( ) ;
449453 for validator in to_remove {
450454 Self :: do_remove_validator ( & validator) ;
Original file line number Diff line number Diff line change @@ -520,7 +520,8 @@ pub mod pallet {
520520
521521 #[ pallet:: storage]
522522 #[ pallet:: getter( fn candidate_whitelist) ]
523- pub type CandidateWhitelist < T : Config > = StorageValue < _ , BTreeSet < T :: AccountId > , ValueQuery > ;
523+ pub type CandidateWhitelist < T : Config > =
524+ StorageValue < _ , Option < BTreeSet < T :: AccountId > > , ValueQuery > ;
524525
525526 #[ pallet:: genesis_config]
526527 pub struct GenesisConfig < T : Config > {
@@ -1057,7 +1058,7 @@ pub mod pallet {
10571058 ) ;
10581059
10591060 ensure ! (
1060- Self :: candidate_whitelist( ) . contains( & stash) ,
1061+ Self :: candidate_whitelist( ) . map_or ( true , |set| set . contains( & stash) ) ,
10611062 Error :: <T >:: NotInAWhitelist
10621063 ) ;
10631064
@@ -1770,7 +1771,7 @@ pub mod pallet {
17701771 #[ pallet:: weight( T :: DbWeight :: get( ) . writes( 1 ) ) ]
17711772 pub fn set_whitelist (
17721773 origin : OriginFor < T > ,
1773- whitelist : BTreeSet < T :: AccountId > ,
1774+ whitelist : Option < BTreeSet < T :: AccountId > > ,
17741775 ) -> DispatchResult {
17751776 ensure_root ( origin) ?;
17761777
Original file line number Diff line number Diff line change @@ -88,9 +88,6 @@ pub fn create_stash_controller<T: Config>(
8888 amount,
8989 destination,
9090 ) ?;
91- let mut whitelist = Staking :: < T > :: candidate_whitelist ( ) ;
92- whitelist. insert ( stash. clone ( ) ) ;
93- Staking :: < T > :: set_whitelist ( RawOrigin :: Root . into ( ) , whitelist) . unwrap ( ) ;
9491
9592 Ok ( ( stash, controller) )
9693}
You can’t perform that action at this time.
0 commit comments