2424// TODO: doc
2525// TODO: re-review this once finished
2626
27- use crate :: { database_thread , jaeger_service , network_service , LogCallback , LogLevel } ;
27+ use crate :: { LogCallback , LogLevel , database_thread , jaeger_service , network_service } ;
2828
2929use futures_channel:: { mpsc, oneshot} ;
3030use futures_lite:: FutureExt as _;
3131use futures_util:: {
32- future,
32+ SinkExt as _ , StreamExt as _ , future,
3333 stream:: { self , FuturesUnordered } ,
34- SinkExt as _, StreamExt as _,
3534} ;
3635use hashbrown:: HashSet ;
3736use rand:: seq:: IteratorRandom ;
@@ -52,9 +51,7 @@ use smoldot::{
5251use std:: {
5352 array,
5453 borrow:: Cow ,
55- cmp,
56- future:: Future ,
57- iter,
54+ cmp, iter,
5855 num:: NonZero ,
5956 pin:: Pin ,
6057 sync:: Arc ,
@@ -227,7 +224,7 @@ impl ConsensusService {
227224 match database. to_chain_information ( & finalized_block_hash) {
228225 Ok ( info) => info,
229226 Err ( full_sqlite:: StorageAccessError :: Corrupted ( err) ) => {
230- return Err ( InitError :: DatabaseCorruption ( err) )
227+ return Err ( InitError :: DatabaseCorruption ( err) ) ;
231228 }
232229 Err ( full_sqlite:: StorageAccessError :: IncompleteStorage )
233230 | Err ( full_sqlite:: StorageAccessError :: UnknownBlock ) => unreachable ! ( ) ,
@@ -240,7 +237,7 @@ impl ConsensusService {
240237 Ok ( Some ( ( code, _) ) ) => code,
241238 Ok ( None ) => return Err ( InitError :: FinalizedCodeMissing ) ,
242239 Err ( full_sqlite:: StorageAccessError :: Corrupted ( err) ) => {
243- return Err ( InitError :: DatabaseCorruption ( err) )
240+ return Err ( InitError :: DatabaseCorruption ( err) ) ;
244241 }
245242 Err ( full_sqlite:: StorageAccessError :: IncompleteStorage )
246243 | Err ( full_sqlite:: StorageAccessError :: UnknownBlock ) => unreachable ! ( ) ,
@@ -253,7 +250,7 @@ impl ConsensusService {
253250 Ok ( Some ( ( hp, _) ) ) => Some ( hp) ,
254251 Ok ( None ) => None ,
255252 Err ( full_sqlite:: StorageAccessError :: Corrupted ( err) ) => {
256- return Err ( InitError :: DatabaseCorruption ( err) )
253+ return Err ( InitError :: DatabaseCorruption ( err) ) ;
257254 }
258255 Err ( full_sqlite:: StorageAccessError :: IncompleteStorage )
259256 | Err ( full_sqlite:: StorageAccessError :: UnknownBlock ) => unreachable ! ( ) ,
@@ -1138,23 +1135,25 @@ impl SyncBackground {
11381135 request : all:: DesiredRequest :: StorageGetMerkleProof {
11391136 block_hash : missing_item. hash ,
11401137 state_trie_root : [ 0 ; 32 ] , // TODO: wrong, but field value unused so it's fine temporarily
1141- keys : vec ! [ trie:: nibbles_to_bytes_suffix_extend(
1142- missing_item
1143- . trie_node_key_nibbles
1144- . into_iter( )
1145- // In order to download more than one item at a time,
1146- // we add some randomly-generated nibbles to the
1147- // requested key. The request will target the missing
1148- // key plus a few other random keys.
1149- . chain( ( 0 ..32 ) . map( |_| {
1150- rand:: Rng :: gen_range(
1151- & mut rand:: thread_rng( ) ,
1152- 0 ..16 ,
1153- )
1154- } ) )
1155- . map( |n| trie:: Nibble :: try_from( n) . unwrap( ) ) ,
1156- )
1157- . collect:: <Vec <_>>( ) ] ,
1138+ keys : vec ! [
1139+ trie:: nibbles_to_bytes_suffix_extend(
1140+ missing_item
1141+ . trie_node_key_nibbles
1142+ . into_iter( )
1143+ // In order to download more than one item at a time,
1144+ // we add some randomly-generated nibbles to the
1145+ // requested key. The request will target the missing
1146+ // key plus a few other random keys.
1147+ . chain( ( 0 ..32 ) . map( |_| {
1148+ rand:: Rng :: gen_range(
1149+ & mut rand:: thread_rng( ) ,
1150+ 0 ..16 ,
1151+ )
1152+ } ) )
1153+ . map( |n| trie:: Nibble :: try_from( n) . unwrap( ) ) ,
1154+ )
1155+ . collect:: <Vec <_>>( ) ,
1156+ ] ,
11581157 } ,
11591158 database_catch_up_type : DbCatchUpType :: Database ,
11601159 } ;
@@ -3042,12 +3041,12 @@ pub async fn execute_block_and_insert(
30423041 Err ( RuntimeCallError :: RuntimeStartError ( error) ) => {
30433042 return Err ( ExecuteBlockError :: VerificationFailure (
30443043 ExecuteBlockVerificationFailureError :: RuntimeStartError ( error) ,
3045- ) )
3044+ ) ) ;
30463045 }
30473046 Err ( RuntimeCallError :: RuntimeExecutionError ( error) ) => {
30483047 return Err ( ExecuteBlockError :: InvalidBlock (
30493048 ExecuteBlockInvalidBlockError :: RuntimeExecutionError ( error) ,
3050- ) )
3049+ ) ) ;
30513050 }
30523051 Err ( RuntimeCallError :: DatabaseParentAccess ( error) ) => {
30533052 return Err ( ExecuteBlockError :: VerificationFailure (
@@ -3058,17 +3057,17 @@ pub async fn execute_block_and_insert(
30583057 parameter : call_parameter. to_owned ( ) ,
30593058 } ,
30603059 } ,
3061- ) )
3060+ ) ) ;
30623061 }
30633062 Err ( RuntimeCallError :: ForbiddenHostFunction ) => {
30643063 return Err ( ExecuteBlockError :: VerificationFailure (
30653064 ExecuteBlockVerificationFailureError :: ForbiddenHostFunction ,
3066- ) )
3065+ ) ) ;
30673066 }
30683067 Err ( RuntimeCallError :: DatabaseInvalidStateTrieVersion ) => {
30693068 return Err ( ExecuteBlockError :: VerificationFailure (
30703069 ExecuteBlockVerificationFailureError :: DatabaseInvalidStateTrieVersion ,
3071- ) )
3070+ ) ) ;
30723071 }
30733072 }
30743073 }
@@ -3086,7 +3085,7 @@ pub async fn execute_block_and_insert(
30863085 Some ( None ) => {
30873086 return Err ( ExecuteBlockError :: InvalidBlock (
30883087 ExecuteBlockInvalidBlockError :: EmptyCode ,
3089- ) )
3088+ ) ) ;
30903089 }
30913090 None => {
30923091 let parent_block_hash = * parent_block_hash;
@@ -3104,7 +3103,7 @@ pub async fn execute_block_and_insert(
31043103 Ok ( None ) => {
31053104 return Err ( ExecuteBlockError :: VerificationFailure (
31063105 ExecuteBlockVerificationFailureError :: ParentCodeEmptyInDatabase ,
3107- ) )
3106+ ) ) ;
31083107 }
31093108 Err ( error) => return Err ( ExecuteBlockError :: VerificationFailure (
31103109 ExecuteBlockVerificationFailureError :: DatabaseParentAccess {
0 commit comments