@@ -77,20 +77,14 @@ impl RocksDbSpawnMode {
77
77
O : Send + ' static ,
78
78
{
79
79
Ok ( match self {
80
- RocksDbSpawnMode :: BlockInPlace => {
81
- tokio:: task:: block_in_place ( move || f ( input) ) ?
82
- } ,
80
+ RocksDbSpawnMode :: BlockInPlace => tokio:: task:: block_in_place ( move || f ( input) ) ?,
83
81
RocksDbSpawnMode :: SpawnBlocking => {
84
82
tokio:: task:: spawn_blocking ( move || f ( input) ) . await ??
85
- } ,
83
+ }
86
84
} )
87
85
}
88
-
89
86
}
90
87
91
-
92
-
93
-
94
88
#[ derive( Clone ) ]
95
89
struct RocksDbStoreExecutor {
96
90
db : Arc < DB > ,
@@ -334,34 +328,45 @@ impl ReadableKeyValueStore for RocksDbStoreInternal {
334
328
let db = self . executor . db . clone ( ) ;
335
329
let mut full_key = self . executor . root_key . to_vec ( ) ;
336
330
full_key. extend ( key) ;
337
- self . spawn_mode . spawn ( move |x| Ok ( db. get ( & x) ?) , full_key) . await
331
+ self . spawn_mode
332
+ . spawn ( move |x| Ok ( db. get ( & x) ?) , full_key)
333
+ . await
338
334
}
339
335
340
336
async fn contains_key ( & self , key : & [ u8 ] ) -> Result < bool , RocksDbStoreError > {
341
337
ensure ! ( key. len( ) <= MAX_KEY_SIZE , RocksDbStoreError :: KeyTooLong ) ;
342
338
let db = self . executor . db . clone ( ) ;
343
339
let mut full_key = self . executor . root_key . to_vec ( ) ;
344
340
full_key. extend ( key) ;
345
- self . spawn_mode . spawn ( move |x| {
346
- let key_may_exist = db. key_may_exist ( & x) ;
347
- if !key_may_exist {
348
- return Ok ( false ) ;
349
- }
350
- Ok ( db. get ( & x) ?. is_some ( ) )
351
- } , full_key) . await
341
+ self . spawn_mode
342
+ . spawn (
343
+ move |x| {
344
+ let key_may_exist = db. key_may_exist ( & x) ;
345
+ if !key_may_exist {
346
+ return Ok ( false ) ;
347
+ }
348
+ Ok ( db. get ( & x) ?. is_some ( ) )
349
+ } ,
350
+ full_key,
351
+ )
352
+ . await
352
353
}
353
354
354
355
async fn contains_keys ( & self , keys : Vec < Vec < u8 > > ) -> Result < Vec < bool > , RocksDbStoreError > {
355
356
let executor = self . executor . clone ( ) ;
356
- self . spawn_mode . spawn ( move |x| executor. contains_keys_internal ( x) , keys) . await
357
+ self . spawn_mode
358
+ . spawn ( move |x| executor. contains_keys_internal ( x) , keys)
359
+ . await
357
360
}
358
361
359
362
async fn read_multi_values_bytes (
360
363
& self ,
361
364
keys : Vec < Vec < u8 > > ,
362
365
) -> Result < Vec < Option < Vec < u8 > > > , RocksDbStoreError > {
363
366
let executor = self . executor . clone ( ) ;
364
- self . spawn_mode . spawn ( move |x| executor. read_multi_values_bytes_internal ( x) , keys) . await
367
+ self . spawn_mode
368
+ . spawn ( move |x| executor. read_multi_values_bytes_internal ( x) , keys)
369
+ . await
365
370
}
366
371
367
372
async fn find_keys_by_prefix (
@@ -370,7 +375,12 @@ impl ReadableKeyValueStore for RocksDbStoreInternal {
370
375
) -> Result < Self :: Keys , RocksDbStoreError > {
371
376
let executor = self . executor . clone ( ) ;
372
377
let key_prefix = key_prefix. to_vec ( ) ;
373
- self . spawn_mode . spawn ( move |x| executor. find_keys_by_prefix_internal ( x) , key_prefix) . await
378
+ self . spawn_mode
379
+ . spawn (
380
+ move |x| executor. find_keys_by_prefix_internal ( x) ,
381
+ key_prefix,
382
+ )
383
+ . await
374
384
}
375
385
376
386
async fn find_key_values_by_prefix (
@@ -379,7 +389,12 @@ impl ReadableKeyValueStore for RocksDbStoreInternal {
379
389
) -> Result < Self :: KeyValues , RocksDbStoreError > {
380
390
let executor = self . executor . clone ( ) ;
381
391
let key_prefix = key_prefix. to_vec ( ) ;
382
- self . spawn_mode . spawn ( move |x| executor. find_key_values_by_prefix_internal ( x) , key_prefix) . await
392
+ self . spawn_mode
393
+ . spawn (
394
+ move |x| executor. find_key_values_by_prefix_internal ( x) ,
395
+ key_prefix,
396
+ )
397
+ . await
383
398
}
384
399
}
385
400
@@ -388,7 +403,9 @@ impl WritableKeyValueStore for RocksDbStoreInternal {
388
403
389
404
async fn write_batch ( & self , batch : Batch ) -> Result < ( ) , RocksDbStoreError > {
390
405
let executor = self . executor . clone ( ) ;
391
- self . spawn_mode . spawn ( move |x| executor. write_batch_internal ( x) , batch) . await
406
+ self . spawn_mode
407
+ . spawn ( move |x| executor. write_batch_internal ( x) , batch)
408
+ . await
392
409
}
393
410
394
411
async fn clear_journal ( & self ) -> Result < ( ) , RocksDbStoreError > {
0 commit comments