@@ -180,13 +180,13 @@ pub use grovedb_merk::proofs::query::query_item::QueryItem;
180
180
pub use grovedb_merk:: proofs:: Query ;
181
181
#[ cfg( feature = "full" ) ]
182
182
use grovedb_merk:: tree:: kv:: ValueDefinedCostType ;
183
+ use grovedb_merk:: ChunkProducer ;
183
184
#[ cfg( feature = "full" ) ]
184
185
use grovedb_merk:: {
185
186
self ,
186
187
tree:: { combine_hash, value_hash} ,
187
188
BatchEntry , CryptoHash , KVIterator , Merk ,
188
189
} ;
189
- use grovedb_merk:: ChunkProducer ;
190
190
#[ cfg( feature = "full" ) ]
191
191
use grovedb_path:: SubtreePath ;
192
192
#[ cfg( feature = "full" ) ]
@@ -217,11 +217,11 @@ use crate::element::helpers::raw_decode;
217
217
pub use crate :: error:: Error ;
218
218
#[ cfg( feature = "full" ) ]
219
219
use crate :: operations:: proof:: util:: hex_to_ascii;
220
+ use crate :: replication:: util_encode_vec_ops;
220
221
#[ cfg( feature = "full" ) ]
221
222
use crate :: util:: { root_merk_optional_tx, storage_context_optional_tx} ;
222
223
#[ cfg( feature = "full" ) ]
223
224
use crate :: Error :: MerkError ;
224
- use crate :: replication:: util_encode_vec_ops;
225
225
226
226
#[ cfg( feature = "full" ) ]
227
227
type Hash = [ u8 ; 32 ] ;
@@ -340,8 +340,7 @@ impl GroveDb {
340
340
tx : & ' db Transaction ,
341
341
batch : Option < & ' db StorageBatch > ,
342
342
grove_version : & GroveVersion ,
343
- ) -> CostResult < Merk < PrefixedRocksDbTransactionContext > , Error >
344
- {
343
+ ) -> CostResult < Merk < PrefixedRocksDbTransactionContext > , Error > {
345
344
let mut cost = OperationCost :: default ( ) ;
346
345
let storage = self
347
346
. db
@@ -354,19 +353,22 @@ impl GroveDb {
354
353
is_sum_tree,
355
354
Some ( & Element :: value_defined_cost_for_serialized_value) ,
356
355
grove_version,
357
- ) . map_err ( |_| {
358
- Error :: CorruptedData ( "cannot open a subtree by prefix with given root key" . to_owned ( ) )
359
- } ) . add_cost ( cost)
360
- }
361
- else {
356
+ )
357
+ . map_err ( |_| {
358
+ Error :: CorruptedData (
359
+ "cannot open a subtree by prefix with given root key" . to_owned ( ) ,
360
+ )
361
+ } )
362
+ . add_cost ( cost)
363
+ } else {
362
364
Merk :: open_base (
363
365
storage,
364
366
false ,
365
367
Some ( & Element :: value_defined_cost_for_serialized_value) ,
366
368
grove_version,
367
- ) . map_err ( |_| {
368
- Error :: CorruptedData ( "cannot open a root subtree by prefix" . to_owned ( ) )
369
- } ) . add_cost ( cost)
369
+ )
370
+ . map_err ( |_| Error :: CorruptedData ( "cannot open a root subtree by prefix" . to_owned ( ) ) )
371
+ . add_cost ( cost)
370
372
}
371
373
}
372
374
@@ -377,7 +379,14 @@ impl GroveDb {
377
379
path : SubtreePath < ' b , B > ,
378
380
tx : & ' tx Transaction < ' db > ,
379
381
grove_version : & GroveVersion ,
380
- ) -> Result < ( Merk < PrefixedRocksDbImmediateStorageContext < ' tx > > , Option < Vec < u8 > > , bool ) , Error >
382
+ ) -> Result <
383
+ (
384
+ Merk < PrefixedRocksDbImmediateStorageContext < ' tx > > ,
385
+ Option < Vec < u8 > > ,
386
+ bool ,
387
+ ) ,
388
+ Error ,
389
+ >
381
390
where
382
391
B : AsRef < [ u8 ] > + ' b ,
383
392
{
@@ -405,19 +414,19 @@ impl GroveDb {
405
414
let is_sum_tree = element. is_sum_tree ( ) ;
406
415
if let Element :: Tree ( root_key, _) | Element :: SumTree ( root_key, ..) = element {
407
416
Ok ( (
408
- Merk :: open_layered_with_root_key (
409
- storage,
410
- root_key. clone ( ) ,
411
- is_sum_tree,
412
- Some ( & Element :: value_defined_cost_for_serialized_value) ,
413
- grove_version,
414
- )
415
- . map_err ( |_| {
416
- Error :: CorruptedData ( "cannot open a subtree with given root key" . to_owned ( ) )
417
- } )
418
- . unwrap ( ) ?,
417
+ Merk :: open_layered_with_root_key (
418
+ storage,
419
+ root_key. clone ( ) ,
420
+ is_sum_tree,
421
+ Some ( & Element :: value_defined_cost_for_serialized_value) ,
422
+ grove_version,
423
+ )
424
+ . map_err ( |_| {
425
+ Error :: CorruptedData ( "cannot open a subtree with given root key" . to_owned ( ) )
426
+ } )
427
+ . unwrap ( ) ?,
419
428
root_key,
420
- is_sum_tree
429
+ is_sum_tree,
421
430
) )
422
431
} else {
423
432
Err ( Error :: CorruptedPath (
@@ -426,16 +435,16 @@ impl GroveDb {
426
435
}
427
436
} else {
428
437
Ok ( (
429
- Merk :: open_base (
430
- storage,
431
- false ,
432
- None :: < & fn ( & [ u8 ] , & GroveVersion ) -> Option < ValueDefinedCostType > > ,
433
- grove_version,
434
- )
435
- . map_err ( |_| Error :: CorruptedData ( "cannot open a the root subtree" . to_owned ( ) ) )
436
- . unwrap ( ) ?,
438
+ Merk :: open_base (
439
+ storage,
440
+ false ,
441
+ None :: < & fn ( & [ u8 ] , & GroveVersion ) -> Option < ValueDefinedCostType > > ,
442
+ grove_version,
443
+ )
444
+ . map_err ( |_| Error :: CorruptedData ( "cannot open a the root subtree" . to_owned ( ) ) )
445
+ . unwrap ( ) ?,
437
446
None ,
438
- false
447
+ false ,
439
448
) )
440
449
}
441
450
}
@@ -513,8 +522,7 @@ impl GroveDb {
513
522
is_sum_tree : bool ,
514
523
batch : Option < & ' db StorageBatch > ,
515
524
grove_version : & GroveVersion ,
516
- ) -> CostResult < Merk < PrefixedRocksDbStorageContext > , Error >
517
- {
525
+ ) -> CostResult < Merk < PrefixedRocksDbStorageContext > , Error > {
518
526
let mut cost = OperationCost :: default ( ) ;
519
527
let storage = self
520
528
. db
@@ -527,19 +535,22 @@ impl GroveDb {
527
535
is_sum_tree,
528
536
Some ( & Element :: value_defined_cost_for_serialized_value) ,
529
537
grove_version,
530
- ) . map_err ( |_| {
531
- Error :: CorruptedData ( "cannot open a subtree by prefix with given root key" . to_owned ( ) )
532
- } ) . add_cost ( cost)
533
- }
534
- else {
538
+ )
539
+ . map_err ( |_| {
540
+ Error :: CorruptedData (
541
+ "cannot open a subtree by prefix with given root key" . to_owned ( ) ,
542
+ )
543
+ } )
544
+ . add_cost ( cost)
545
+ } else {
535
546
Merk :: open_base (
536
547
storage,
537
548
false ,
538
549
Some ( & Element :: value_defined_cost_for_serialized_value) ,
539
550
grove_version,
540
- ) . map_err ( |_| {
541
- Error :: CorruptedData ( "cannot open a root subtree by prefix" . to_owned ( ) )
542
- } ) . add_cost ( cost)
551
+ )
552
+ . map_err ( |_| Error :: CorruptedData ( "cannot open a root subtree by prefix" . to_owned ( ) ) )
553
+ . add_cost ( cost)
543
554
}
544
555
}
545
556
0 commit comments