Skip to content

Commit

Permalink
refactor: better type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Dec 30, 2024
1 parent 995aec7 commit dfcef7a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions grovedb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ pub type Transaction<'db> = <RocksDbStorage as Storage<'db>>::Transaction;
#[cfg(feature = "full")]
pub type TransactionArg<'db, 'a> = Option<&'a Transaction<'db>>;

/// Type alias for the return type of the `verify_merk_and_submerks` and `verify_grovedb` functions.
/// It represents a mapping of paths (as vectors of vectors of bytes) to a tuple
/// of three cryptographic hashes: the root hash, the combined value hash, and the expected value hash.
type VerificationIssues = HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>;

/// Type alias for the return type of the `open_merk_for_replication` function.
/// It represents a tuple containing:
/// - A `Merk` instance with a prefixed RocksDB immediate storage context.
/// - An optional `root_key`, represented as a vector of bytes.
/// - A boolean indicating whether the Merk is a sum tree.
type OpenedMerkForReplication<'tx> = (Merk<PrefixedRocksDbImmediateStorageContext<'tx>>, Option<Vec<u8>>, bool);

#[cfg(feature = "full")]
impl GroveDb {
/// Opens a given path
Expand Down Expand Up @@ -377,14 +389,7 @@ impl GroveDb {
path: SubtreePath<'b, B>,
tx: &'tx Transaction<'db>,
grove_version: &GroveVersion,
) -> Result<
(
Merk<PrefixedRocksDbImmediateStorageContext<'tx>>,
Option<Vec<u8>>,
bool,
),
Error,
>
) -> Result<OpenedMerkForReplication<'tx>, Error>
where
B: AsRef<[u8]> + 'b,
{
Expand Down Expand Up @@ -1029,7 +1034,7 @@ impl GroveDb {
verify_references: bool,
allow_cache: bool,
grove_version: &GroveVersion,
) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> {
) -> Result<VerificationIssues, Error> {
if let Some(transaction) = transaction {
let root_merk = self
.open_transactional_merk_at_path(
Expand Down Expand Up @@ -1073,7 +1078,7 @@ impl GroveDb {
verify_references: bool,
allow_cache: bool,
grove_version: &GroveVersion,
) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> {
) -> Result<VerificationIssues, Error> {
let mut all_query = Query::new();
all_query.insert_all();

Expand Down Expand Up @@ -1217,7 +1222,7 @@ impl GroveDb {
verify_references: bool,
allow_cache: bool,
grove_version: &GroveVersion,
) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> {
) -> Result<VerificationIssues, Error> {

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

View workflow job for this annotation

GitHub Actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7) --> grovedb/src/lib.rs:1216:5 | 1216 | / fn verify_merk_and_submerks_in_transaction<'db, B: AsRef<[u8]>, S: StorageContext<'db>>( 1217 | | &'db self, 1218 | | merk: Merk<S>, 1219 | | path: &SubtreePath<B>, ... | 1224 | | grove_version: &GroveVersion, 1225 | | ) -> Result<VerificationIssues, Error> { | |__________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
let mut all_query = Query::new();
all_query.insert_all();

Expand Down

0 comments on commit dfcef7a

Please sign in to comment.