@@ -576,9 +576,9 @@ where
576576
577577 // the block is lower than our last finalized block so it must revert
578578 // finality, refusing import.
579- if status == blockchain:: BlockStatus :: Unknown &&
580- * import_headers. post ( ) . number ( ) <= info. finalized_number &&
581- !gap_block
579+ if status == blockchain:: BlockStatus :: Unknown
580+ && * import_headers. post ( ) . number ( ) <= info. finalized_number
581+ && !gap_block
582582 {
583583 return Err ( sp_blockchain:: Error :: NotInFinalizedChain ) ;
584584 }
@@ -587,8 +587,9 @@ where
587587 // but the general goal is to only make notifications when we are already fully synced
588588 // and get a new chain head.
589589 let make_notifications = match origin {
590- BlockOrigin :: NetworkBroadcast | BlockOrigin :: Own | BlockOrigin :: ConsensusBroadcast =>
591- true ,
590+ BlockOrigin :: NetworkBroadcast | BlockOrigin :: Own | BlockOrigin :: ConsensusBroadcast => {
591+ true
592+ } ,
592593 BlockOrigin :: Genesis | BlockOrigin :: NetworkInitialSync | BlockOrigin :: File => false ,
593594 } ;
594595
@@ -627,19 +628,17 @@ where
627628 None
628629 } else {
629630 // Fall back to key-value import if no trie nodes
630- Self :: import_state_from_key_values (
631+ self . import_state_from_key_values (
631632 changes. state ,
632633 & mut operation. op ,
633- & self . executor ,
634634 import_headers. post ( ) . state_root ( ) ,
635635 ) ?
636636 }
637637 } else {
638638 // Fall back to key-value import
639- Self :: import_state_from_key_values (
639+ self . import_state_from_key_values (
640640 changes. state ,
641641 & mut operation. op ,
642- & self . executor ,
643642 import_headers. post ( ) . state_root ( ) ,
644643 ) ?
645644 }
@@ -663,11 +662,12 @@ where
663662 ) ?;
664663 }
665664
666- let is_new_best = !gap_block &&
667- ( finalized ||
668- match fork_choice {
669- ForkChoiceStrategy :: LongestChain =>
670- import_headers. post ( ) . number ( ) > & info. best_number ,
665+ let is_new_best = !gap_block
666+ && ( finalized
667+ || match fork_choice {
668+ ForkChoiceStrategy :: LongestChain => {
669+ import_headers. post ( ) . number ( ) > & info. best_number
670+ } ,
671671 ForkChoiceStrategy :: Custom ( v) => v,
672672 } ) ;
673673
@@ -786,18 +786,21 @@ where
786786 let state_action = std:: mem:: replace ( & mut import_block. state_action , StateAction :: Skip ) ;
787787 let ( enact_state, storage_changes) = match ( self . block_status ( * parent_hash) ?, state_action)
788788 {
789- ( BlockStatus :: KnownBad , _) =>
790- return Ok ( PrepareStorageChangesResult :: Discard ( ImportResult :: KnownBad ) ) ,
789+ ( BlockStatus :: KnownBad , _) => {
790+ return Ok ( PrepareStorageChangesResult :: Discard ( ImportResult :: KnownBad ) )
791+ } ,
791792 (
792793 BlockStatus :: InChainPruned ,
793794 StateAction :: ApplyChanges ( sc_consensus:: StorageChanges :: Changes ( _) ) ,
794795 ) => return Ok ( PrepareStorageChangesResult :: Discard ( ImportResult :: MissingState ) ) ,
795796 ( _, StateAction :: ApplyChanges ( changes) ) => ( true , Some ( changes) ) ,
796- ( BlockStatus :: Unknown , _) =>
797- return Ok ( PrepareStorageChangesResult :: Discard ( ImportResult :: UnknownParent ) ) ,
797+ ( BlockStatus :: Unknown , _) => {
798+ return Ok ( PrepareStorageChangesResult :: Discard ( ImportResult :: UnknownParent ) )
799+ } ,
798800 ( _, StateAction :: Skip ) => ( false , None ) ,
799- ( BlockStatus :: InChainPruned , StateAction :: Execute ) =>
800- return Ok ( PrepareStorageChangesResult :: Discard ( ImportResult :: MissingState ) ) ,
801+ ( BlockStatus :: InChainPruned , StateAction :: Execute ) => {
802+ return Ok ( PrepareStorageChangesResult :: Discard ( ImportResult :: MissingState ) )
803+ } ,
801804 ( BlockStatus :: InChainPruned , StateAction :: ExecuteIfPossible ) => ( false , None ) ,
802805 ( _, StateAction :: Execute ) => ( true , None ) ,
803806 ( _, StateAction :: ExecuteIfPossible ) => ( true , None ) ,
@@ -1096,12 +1099,13 @@ where
10961099
10971100 let hash_and_number = self . backend . blockchain ( ) . number ( hash) ?. map ( |n| ( hash, n) ) ;
10981101 match hash_and_number {
1099- Some ( ( hash, number) ) =>
1102+ Some ( ( hash, number) ) => {
11001103 if self . backend . have_state_at ( hash, number) {
11011104 Ok ( BlockStatus :: InChainWithState )
11021105 } else {
11031106 Ok ( BlockStatus :: InChainPruned )
1104- } ,
1107+ }
1108+ } ,
11051109 None => Ok ( BlockStatus :: Unknown ) ,
11061110 }
11071111 }
@@ -1167,9 +1171,9 @@ where
11671171
11681172 /// Helper to import state from key-values (original reset_storage path).
11691173 fn import_state_from_key_values (
1174+ & self ,
11701175 state : KeyValueStates ,
11711176 op : & mut B :: BlockImportOperation ,
1172- executor : & E ,
11731177 expected_state_root : & Block :: Hash ,
11741178 ) -> sp_blockchain:: Result < Option < ( StorageCollection , ChildStorageCollection ) > > {
11751179 let mut storage = sp_storage:: Storage :: default ( ) ;
@@ -1183,8 +1187,9 @@ where
11831187 let storage_key = PrefixedStorageKey :: new_ref ( & parent_storage) ;
11841188 let storage_key = match ChildType :: from_prefixed_key ( storage_key) {
11851189 Some ( ( ChildType :: ParentKeyId , storage_key) ) => storage_key,
1186- None =>
1187- return Err ( Error :: Backend ( "Invalid child storage key." . to_string ( ) ) ) ,
1190+ None => {
1191+ return Err ( Error :: Backend ( "Invalid child storage key." . to_string ( ) ) )
1192+ } ,
11881193 } ;
11891194 let entry = storage
11901195 . children_default
@@ -1202,7 +1207,7 @@ where
12021207
12031208 // This is used by fast sync for runtime version to be resolvable from changes.
12041209 let state_version =
1205- resolve_state_version_from_wasm :: < _ , HashingFor < Block > > ( & storage, executor) ?;
1210+ resolve_state_version_from_wasm :: < _ , HashingFor < Block > > ( & storage, & self . executor ) ?;
12061211 let state_root = op. reset_storage ( storage, state_version) ?;
12071212 if state_root != * expected_state_root {
12081213 // State root mismatch when importing state. This should not happen in
@@ -1292,8 +1297,9 @@ where
12921297 let child_info = |storage_key : & Vec < u8 > | -> sp_blockchain:: Result < ChildInfo > {
12931298 let storage_key = PrefixedStorageKey :: new_ref ( storage_key) ;
12941299 match ChildType :: from_prefixed_key ( storage_key) {
1295- Some ( ( ChildType :: ParentKeyId , storage_key) ) =>
1296- Ok ( ChildInfo :: new_default ( storage_key) ) ,
1300+ Some ( ( ChildType :: ParentKeyId , storage_key) ) => {
1301+ Ok ( ChildInfo :: new_default ( storage_key) )
1302+ } ,
12971303 None => Err ( Error :: Backend ( "Invalid child storage key." . to_string ( ) ) ) ,
12981304 }
12991305 } ;
@@ -1353,9 +1359,9 @@ where
13531359 }
13541360 total_size += size;
13551361
1356- if current_child. is_none ( ) &&
1357- sp_core:: storage:: well_known_keys:: is_child_storage_key ( next_key. as_slice ( ) ) &&
1358- !child_roots. contains ( value. as_slice ( ) )
1362+ if current_child. is_none ( )
1363+ && sp_core:: storage:: well_known_keys:: is_child_storage_key ( next_key. as_slice ( ) )
1364+ && !child_roots. contains ( value. as_slice ( ) )
13591365 {
13601366 child_roots. insert ( value. clone ( ) ) ;
13611367 switch_child_key = Some ( ( next_key. clone ( ) , value. clone ( ) ) ) ;
@@ -1860,10 +1866,12 @@ where
18601866 . block_status ( hash)
18611867 . map_err ( |e| ConsensusError :: ClientImport ( e. to_string ( ) ) ) ?
18621868 {
1863- BlockStatus :: InChainWithState | BlockStatus :: Queued =>
1864- return Ok ( ImportResult :: AlreadyInChain ) ,
1865- BlockStatus :: InChainPruned if !import_existing =>
1866- return Ok ( ImportResult :: AlreadyInChain ) ,
1869+ BlockStatus :: InChainWithState | BlockStatus :: Queued => {
1870+ return Ok ( ImportResult :: AlreadyInChain )
1871+ } ,
1872+ BlockStatus :: InChainPruned if !import_existing => {
1873+ return Ok ( ImportResult :: AlreadyInChain )
1874+ } ,
18671875 BlockStatus :: InChainPruned => { } ,
18681876 BlockStatus :: Unknown => { } ,
18691877 BlockStatus :: KnownBad => return Ok ( ImportResult :: KnownBad ) ,
@@ -2029,8 +2037,9 @@ where
20292037
20302038 fn block ( & self , hash : Block :: Hash ) -> sp_blockchain:: Result < Option < SignedBlock < Block > > > {
20312039 Ok ( match ( self . header ( hash) ?, self . body ( hash) ?, self . justifications ( hash) ?) {
2032- ( Some ( header) , Some ( extrinsics) , justifications) =>
2033- Some ( SignedBlock { block : Block :: new ( header, extrinsics) , justifications } ) ,
2040+ ( Some ( header) , Some ( extrinsics) , justifications) => {
2041+ Some ( SignedBlock { block : Block :: new ( header, extrinsics) , justifications } )
2042+ } ,
20342043 _ => None ,
20352044 } )
20362045 }
0 commit comments