Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Dec 26, 2024
1 parent 70460eb commit 83b8e89
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 143 deletions.
99 changes: 55 additions & 44 deletions grovedb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ pub use grovedb_merk::proofs::query::query_item::QueryItem;
pub use grovedb_merk::proofs::Query;
#[cfg(feature = "full")]
use grovedb_merk::tree::kv::ValueDefinedCostType;
use grovedb_merk::ChunkProducer;

Check warning on line 183 in grovedb/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `grovedb_merk::ChunkProducer`

warning: unused import: `grovedb_merk::ChunkProducer` --> grovedb/src/lib.rs:183:5 | 183 | use grovedb_merk::ChunkProducer; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
#[cfg(feature = "full")]
use grovedb_merk::{
self,
tree::{combine_hash, value_hash},
BatchEntry, CryptoHash, KVIterator, Merk,
};
use grovedb_merk::ChunkProducer;
#[cfg(feature = "full")]
use grovedb_path::SubtreePath;
#[cfg(feature = "full")]
Expand Down Expand Up @@ -217,11 +217,11 @@ use crate::element::helpers::raw_decode;
pub use crate::error::Error;
#[cfg(feature = "full")]
use crate::operations::proof::util::hex_to_ascii;
use crate::replication::util_encode_vec_ops;

Check warning on line 220 in grovedb/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `crate::replication::util_encode_vec_ops`

warning: unused import: `crate::replication::util_encode_vec_ops` --> grovedb/src/lib.rs:220:5 | 220 | use crate::replication::util_encode_vec_ops; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#[cfg(feature = "full")]
use crate::util::{root_merk_optional_tx, storage_context_optional_tx};
#[cfg(feature = "full")]
use crate::Error::MerkError;
use crate::replication::util_encode_vec_ops;

#[cfg(feature = "full")]
type Hash = [u8; 32];
Expand Down Expand Up @@ -340,8 +340,7 @@ impl GroveDb {
tx: &'db Transaction,
batch: Option<&'db StorageBatch>,
grove_version: &GroveVersion,
) -> CostResult<Merk<PrefixedRocksDbTransactionContext>, Error>
{
) -> CostResult<Merk<PrefixedRocksDbTransactionContext>, Error> {

Check warning on line 343 in grovedb/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

elided lifetime has a name

warning: elided lifetime has a name --> grovedb/src/lib.rs:343:26 | 335 | fn open_transactional_merk_by_prefix<'db>( | --- lifetime `'db` declared here ... 343 | ) -> CostResult<Merk<PrefixedRocksDbTransactionContext>, Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this elided lifetime gets resolved as `'db`
let mut cost = OperationCost::default();
let storage = self
.db
Expand All @@ -354,19 +353,22 @@ impl GroveDb {
is_sum_tree,
Some(&Element::value_defined_cost_for_serialized_value),
grove_version,
).map_err(|_| {
Error::CorruptedData("cannot open a subtree by prefix with given root key".to_owned())
}).add_cost(cost)
}
else {
)
.map_err(|_| {
Error::CorruptedData(
"cannot open a subtree by prefix with given root key".to_owned(),
)
})
.add_cost(cost)
} else {
Merk::open_base(
storage,
false,
Some(&Element::value_defined_cost_for_serialized_value),
grove_version,
).map_err(|_| {
Error::CorruptedData("cannot open a root subtree by prefix".to_owned())
}).add_cost(cost)
)
.map_err(|_| Error::CorruptedData("cannot open a root subtree by prefix".to_owned()))
.add_cost(cost)
}
}

Expand All @@ -377,7 +379,14 @@ impl GroveDb {
path: SubtreePath<'b, B>,
tx: &'tx Transaction<'db>,
grove_version: &GroveVersion,
) -> Result<(Merk<PrefixedRocksDbImmediateStorageContext<'tx>>, Option<Vec<u8>>, bool), Error>
) -> Result<
(
Merk<PrefixedRocksDbImmediateStorageContext<'tx>>,
Option<Vec<u8>>,
bool,
),
Error,
>

Check warning on line 389 in grovedb/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

very complex type used. Consider factoring parts into `type` definitions

warning: very complex type used. Consider factoring parts into `type` definitions --> grovedb/src/lib.rs:382:10 | 382 | ) -> Result< | __________^ 383 | | ( 384 | | Merk<PrefixedRocksDbImmediateStorageContext<'tx>>, 385 | | Option<Vec<u8>>, ... | 388 | | Error, 389 | | > | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
where
B: AsRef<[u8]> + 'b,
{
Expand Down Expand Up @@ -405,19 +414,19 @@ impl GroveDb {
let is_sum_tree = element.is_sum_tree();
if let Element::Tree(root_key, _) | Element::SumTree(root_key, ..) = element {
Ok((
Merk::open_layered_with_root_key(
storage,
root_key.clone(),
is_sum_tree,
Some(&Element::value_defined_cost_for_serialized_value),
grove_version,
)
.map_err(|_| {
Error::CorruptedData("cannot open a subtree with given root key".to_owned())
})
.unwrap()?,
Merk::open_layered_with_root_key(
storage,
root_key.clone(),
is_sum_tree,
Some(&Element::value_defined_cost_for_serialized_value),
grove_version,
)
.map_err(|_| {
Error::CorruptedData("cannot open a subtree with given root key".to_owned())
})
.unwrap()?,
root_key,
is_sum_tree
is_sum_tree,
))
} else {
Err(Error::CorruptedPath(
Expand All @@ -426,16 +435,16 @@ impl GroveDb {
}
} else {
Ok((
Merk::open_base(
storage,
false,
None::<&fn(&[u8], &GroveVersion) -> Option<ValueDefinedCostType>>,
grove_version,
)
.map_err(|_| Error::CorruptedData("cannot open a the root subtree".to_owned()))
.unwrap()?,
Merk::open_base(
storage,
false,
None::<&fn(&[u8], &GroveVersion) -> Option<ValueDefinedCostType>>,
grove_version,
)
.map_err(|_| Error::CorruptedData("cannot open a the root subtree".to_owned()))
.unwrap()?,
None,
false
false,
))
}
}
Expand Down Expand Up @@ -513,8 +522,7 @@ impl GroveDb {
is_sum_tree: bool,
batch: Option<&'db StorageBatch>,
grove_version: &GroveVersion,
) -> CostResult<Merk<PrefixedRocksDbStorageContext>, Error>
{
) -> CostResult<Merk<PrefixedRocksDbStorageContext>, Error> {

Check warning on line 525 in grovedb/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

elided lifetime has a name

warning: elided lifetime has a name --> grovedb/src/lib.rs:525:26 | 518 | fn open_non_transactional_merk_by_prefix<'db>( | --- lifetime `'db` declared here ... 525 | ) -> CostResult<Merk<PrefixedRocksDbStorageContext>, Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this elided lifetime gets resolved as `'db`
let mut cost = OperationCost::default();
let storage = self
.db
Expand All @@ -527,19 +535,22 @@ impl GroveDb {
is_sum_tree,
Some(&Element::value_defined_cost_for_serialized_value),
grove_version,
).map_err(|_| {
Error::CorruptedData("cannot open a subtree by prefix with given root key".to_owned())
}).add_cost(cost)
}
else {
)
.map_err(|_| {
Error::CorruptedData(
"cannot open a subtree by prefix with given root key".to_owned(),
)
})
.add_cost(cost)
} else {
Merk::open_base(
storage,
false,
Some(&Element::value_defined_cost_for_serialized_value),
grove_version,
).map_err(|_| {
Error::CorruptedData("cannot open a root subtree by prefix".to_owned())
}).add_cost(cost)
)
.map_err(|_| Error::CorruptedData("cannot open a root subtree by prefix".to_owned()))
.add_cost(cost)
}
}

Expand Down
Loading

0 comments on commit 83b8e89

Please sign in to comment.