Skip to content

Commit

Permalink
added option to allow cache to visualize_verify_grovedb
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Aug 20, 2024
1 parent d7f01a1 commit b0a360f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion grovedb/src/batch/just_in_time_cost_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ mod tests {
.cost;

let issues = db
.visualize_verify_grovedb(Some(&tx), true, &Default::default())
.visualize_verify_grovedb(Some(&tx), true, false, &Default::default())
.unwrap();
assert_eq!(
issues.len(),
Expand Down
2 changes: 1 addition & 1 deletion grovedb/src/batch/multi_insert_cost_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ mod tests {
);

let issues = db
.visualize_verify_grovedb(Some(&tx), true, &Default::default())
.visualize_verify_grovedb(Some(&tx), true, false, &Default::default())
.unwrap();
assert_eq!(
issues.len(),
Expand Down
10 changes: 5 additions & 5 deletions grovedb/src/batch/single_insert_cost_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ mod tests {
);

let issues = db
.visualize_verify_grovedb(Some(&tx), true, &Default::default())
.visualize_verify_grovedb(Some(&tx), true, false, &Default::default())
.unwrap();
assert_eq!(
issues.len(),
Expand Down Expand Up @@ -1082,7 +1082,7 @@ mod tests {
);

let issues = db
.visualize_verify_grovedb(Some(&tx), true, &Default::default())
.visualize_verify_grovedb(Some(&tx), true, false, &Default::default())
.unwrap();
assert_eq!(
issues.len(),
Expand Down Expand Up @@ -1362,7 +1362,7 @@ mod tests {
);

let issues = db
.visualize_verify_grovedb(Some(&tx), true, &Default::default())
.visualize_verify_grovedb(Some(&tx), true, false, &Default::default())
.unwrap();
assert_eq!(
issues.len(),
Expand Down Expand Up @@ -1546,7 +1546,7 @@ mod tests {
);

let issues = db
.visualize_verify_grovedb(Some(&tx), true, &Default::default())
.visualize_verify_grovedb(Some(&tx), true, false, &Default::default())
.unwrap();
assert_eq!(
issues.len(),
Expand Down Expand Up @@ -1640,7 +1640,7 @@ mod tests {
);

let issues = db
.visualize_verify_grovedb(Some(&tx), true, &Default::default())
.visualize_verify_grovedb(Some(&tx), true, false, &Default::default())
.unwrap();
assert_eq!(
issues.len(),
Expand Down
14 changes: 9 additions & 5 deletions grovedb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,11 @@ impl GroveDb {
&self,
transaction: TransactionArg,
verify_references: bool,
allow_cache: bool,
grove_version: &GroveVersion,
) -> Result<HashMap<String, (String, String, String)>, Error> {
Ok(self
.verify_grovedb(transaction, verify_references, grove_version)?
.verify_grovedb(transaction, verify_references, allow_cache, grove_version)?
.iter()
.map(|(path, (root_hash, expected, actual))| {
(
Expand All @@ -929,6 +930,7 @@ impl GroveDb {
&self,
transaction: TransactionArg,
verify_references: bool,
allow_cache: bool,
grove_version: &GroveVersion,
) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> {

Check warning on line 935 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:935:10 | 935 | ) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity = note: `#[warn(clippy::type_complexity)]` on by default
if let Some(transaction) = transaction {
Expand All @@ -946,6 +948,7 @@ impl GroveDb {
None,
transaction,
verify_references,
allow_cache,
grove_version,
)
} else {
Expand All @@ -957,6 +960,7 @@ impl GroveDb {
&SubtreePath::empty(),
None,
verify_references,
allow_cache,
grove_version,
)
}
Expand All @@ -970,13 +974,12 @@ impl GroveDb {
path: &SubtreePath<B>,
batch: Option<&'db StorageBatch>,
verify_references: bool,
allow_cache: bool,
grove_version: &GroveVersion,
) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> {

Check warning on line 979 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:979:10 | 979 | ) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
let mut all_query = Query::new();
all_query.insert_all();

let allow_cache = true;

let mut issues = HashMap::new();
let mut element_iterator = KVIterator::new(merk.storage.raw_iter(), &all_query).unwrap();

Expand Down Expand Up @@ -1024,6 +1027,7 @@ impl GroveDb {
&new_path_ref,
batch,
verify_references,
true,
grove_version,
)?);
}
Expand Down Expand Up @@ -1114,13 +1118,12 @@ impl GroveDb {
batch: Option<&'db StorageBatch>,
transaction: &Transaction,
verify_references: bool,
allow_cache: bool,
grove_version: &GroveVersion,
) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> {

Check warning on line 1123 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:1114:5 | 1114 | / fn verify_merk_and_submerks_in_transaction<'db, B: AsRef<[u8]>, S: StorageContext<'db>>( 1115 | | &'db self, 1116 | | merk: Merk<S>, 1117 | | path: &SubtreePath<B>, ... | 1122 | | grove_version: &GroveVersion, 1123 | | ) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> { | |___________________________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments

Check warning on line 1123 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:1123:10 | 1123 | ) -> Result<HashMap<Vec<Vec<u8>>, (CryptoHash, CryptoHash, CryptoHash)>, Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
let mut all_query = Query::new();
all_query.insert_all();

let allow_cache = true;

let mut issues = HashMap::new();
let mut element_iterator = KVIterator::new(merk.storage.raw_iter(), &all_query).unwrap();

Expand Down Expand Up @@ -1170,6 +1173,7 @@ impl GroveDb {
batch,
transaction,
verify_references,
true,
grove_version,
)?);
}
Expand Down
15 changes: 10 additions & 5 deletions grovedb/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3990,7 +3990,12 @@ mod tests {
));

// `verify_grovedb` must identify issues
assert!(db.verify_grovedb(None, true, grove_version).unwrap().len() > 0);
assert!(
db.verify_grovedb(None, true, false, grove_version)
.unwrap()
.len()
> 0
);
}

#[test]
Expand Down Expand Up @@ -4043,7 +4048,7 @@ mod tests {
.unwrap();

assert!(db
.verify_grovedb(None, true, grove_version)
.verify_grovedb(None, true, false, grove_version)
.unwrap()
.is_empty());

Expand All @@ -4060,7 +4065,7 @@ mod tests {
.unwrap();

assert!(!db
.verify_grovedb(None, true, grove_version)
.verify_grovedb(None, true, false, grove_version)
.unwrap()
.is_empty());
}
Expand Down Expand Up @@ -4098,7 +4103,7 @@ mod tests {
.unwrap();

assert!(db
.verify_grovedb(None, true, grove_version)
.verify_grovedb(None, true, false, grove_version)
.unwrap()
.is_empty());

Expand All @@ -4115,7 +4120,7 @@ mod tests {
.unwrap();

assert!(!db
.verify_grovedb(None, true, grove_version)
.verify_grovedb(None, true, false, grove_version)
.unwrap()
.is_empty());
}
Expand Down

0 comments on commit b0a360f

Please sign in to comment.