Skip to content

Commit

Permalink
trying cache true
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Aug 20, 2024
1 parent 354a66c commit c423799
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions grovedb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ pub use crate::error::Error;
use crate::util::{root_merk_optional_tx, storage_context_optional_tx};
#[cfg(feature = "full")]
use crate::Error::MerkError;
use crate::operations::proof::util::hex_to_ascii;

#[cfg(feature = "full")]
type Hash = [u8; 32];
Expand Down Expand Up @@ -974,7 +975,8 @@ impl GroveDb {
let mut all_query = Query::new();
all_query.insert_all();

let _in_sum_tree = merk.is_sum_tree;
let allow_cache = true;

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

Expand All @@ -985,14 +987,14 @@ impl GroveDb {
let (kv_value, element_value_hash) = merk
.get_value_and_value_hash(
&key,
false,
allow_cache,
None::<&fn(&[u8], &GroveVersion) -> Option<ValueDefinedCostType>>,
grove_version,
)
.unwrap()
.map_err(MerkError)?
.ok_or(Error::CorruptedData(
"expected merk to contain value at key".to_string(),
format!("expected merk to contain value at key {} for {}", hex_to_ascii(&key), element.type_str())
))?;
let new_path = path.derive_owned_with_child(key);
let new_path_ref = SubtreePath::from(&new_path);
Expand Down Expand Up @@ -1027,14 +1029,14 @@ impl GroveDb {
let (kv_value, element_value_hash) = merk
.get_value_and_value_hash(
&key,
false,
allow_cache,
None::<&fn(&[u8], &GroveVersion) -> Option<ValueDefinedCostType>>,
grove_version,
)
.unwrap()
.map_err(MerkError)?
.ok_or(Error::CorruptedData(
"expected merk to contain value at key".to_string(),
format!("expected merk to contain value at key {} for {}", hex_to_ascii(&key), element.type_str())
))?;
let actual_value_hash = value_hash(&kv_value).unwrap();
if actual_value_hash != element_value_hash {
Expand All @@ -1054,14 +1056,14 @@ impl GroveDb {
let (kv_value, element_value_hash) = merk
.get_value_and_value_hash(
&key,
false,
allow_cache,
None::<&fn(&[u8], &GroveVersion) -> Option<ValueDefinedCostType>>,
grove_version,
)
.unwrap()
.map_err(MerkError)?
.ok_or(Error::CorruptedData(
"expected merk to contain value at key".to_string(),
format!("expected merk to contain value at key {} for reference", hex_to_ascii(&key))
))?;

let referenced_value_hash = {
Expand All @@ -1073,7 +1075,7 @@ impl GroveDb {
let item = self
.follow_reference(
(full_path.as_slice()).into(),
false,
allow_cache,
None,
grove_version,
)
Expand Down Expand Up @@ -1112,7 +1114,8 @@ impl GroveDb {
let mut all_query = Query::new();
all_query.insert_all();

let _in_sum_tree = merk.is_sum_tree;
let allow_cache = true;

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

Expand All @@ -1123,14 +1126,14 @@ impl GroveDb {
let (kv_value, element_value_hash) = merk
.get_value_and_value_hash(
&key,
false,
allow_cache,
None::<&fn(&[u8], &GroveVersion) -> Option<ValueDefinedCostType>>,
grove_version,
)
.unwrap()
.map_err(MerkError)?
.ok_or(Error::CorruptedData(
"expected merk to contain value at key".to_string(),
format!("expected merk to contain value at key {} for {}", hex_to_ascii(&key), element.type_str())
))?;
let new_path = path.derive_owned_with_child(key);
let new_path_ref = SubtreePath::from(&new_path);
Expand Down Expand Up @@ -1167,14 +1170,14 @@ impl GroveDb {
let (kv_value, element_value_hash) = merk
.get_value_and_value_hash(
&key,
false,
allow_cache,
None::<&fn(&[u8], &GroveVersion) -> Option<ValueDefinedCostType>>,
grove_version,
)
.unwrap()
.map_err(MerkError)?
.ok_or(Error::CorruptedData(
"expected merk to contain value at key".to_string(),
format!("expected merk to contain value at key {} for {}", hex_to_ascii(&key), element.type_str())
))?;
let actual_value_hash = value_hash(&kv_value).unwrap();
if actual_value_hash != element_value_hash {
Expand All @@ -1194,14 +1197,14 @@ impl GroveDb {
let (kv_value, element_value_hash) = merk
.get_value_and_value_hash(
&key,
false,
allow_cache,
None::<&fn(&[u8], &GroveVersion) -> Option<ValueDefinedCostType>>,
grove_version,
)
.unwrap()
.map_err(MerkError)?
.ok_or(Error::CorruptedData(
"expected merk to contain value at key".to_string(),
format!("expected merk to contain value at key {} for reference", hex_to_ascii(&key))
))?;

let referenced_value_hash = {
Expand All @@ -1213,7 +1216,7 @@ impl GroveDb {
let item = self
.follow_reference(
(full_path.as_slice()).into(),
false,
allow_cache,
Some(transaction),
grove_version,
)
Expand Down

0 comments on commit c423799

Please sign in to comment.