Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Sep 27, 2023
1 parent 7d0899c commit 619f534
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion grovedb/src/batch/estimated_costs/average_case_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ mod tests {
seek_count: 5, // todo: why is this 5
storage_cost: StorageCost {
added_bytes: 115,
replaced_bytes: 106,
replaced_bytes: 75,
removed_bytes: NoStorageRemoval,
},
storage_loaded_bytes: 109,
Expand Down
5 changes: 1 addition & 4 deletions grovedb/src/batch/single_insert_cost_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@ mod tests {
// Replaced bytes

// 37 + 36 = 74 (key is not replaced) //needs update
// We instead are getting 106, because we are paying for (+ hash - key byte
// size) this means 31 extra bytes.
// In reality though we really are replacing 106 bytes. TBD what to do.

// Hash node calls 8
// 1 to get tree hash
Expand All @@ -359,7 +356,7 @@ mod tests {
seek_count: 5,
storage_cost: StorageCost {
added_bytes: 115,
replaced_bytes: 106, // todo: this should actually be less
replaced_bytes: 75,
removed_bytes: NoStorageRemoval,
},
storage_loaded_bytes: 71, // todo: verify and explain
Expand Down
4 changes: 2 additions & 2 deletions grovedb/src/batch/single_sum_item_insert_cost_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ mod tests {
seek_count: 5,
storage_cost: StorageCost {
added_bytes: 124,
replaced_bytes: 106, // todo: this should actually be less
replaced_bytes: 75,
removed_bytes: NoStorageRemoval,
},
storage_loaded_bytes: 71, // todo: verify and explain
Expand Down Expand Up @@ -287,7 +287,7 @@ mod tests {
seek_count: 5,
storage_cost: StorageCost {
added_bytes: 124,
replaced_bytes: 107, // todo: this should actually be less
replaced_bytes: 84,
removed_bytes: NoStorageRemoval,
},
storage_loaded_bytes: 72, // todo: verify and explain
Expand Down
6 changes: 3 additions & 3 deletions grovedb/src/operations/insert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ mod tests {
seek_count: 7,
storage_cost: StorageCost {
added_bytes: 170,
replaced_bytes: 209, // todo: verify
replaced_bytes: 217,
removed_bytes: NoStorageRemoval
},
storage_loaded_bytes: 232,
Expand Down Expand Up @@ -955,7 +955,7 @@ mod tests {
seek_count: 7,
storage_cost: StorageCost {
added_bytes: 170,
replaced_bytes: 211, // todo: verify
replaced_bytes: 217, // todo: verify
removed_bytes: NoStorageRemoval
},
storage_loaded_bytes: 237,
Expand Down Expand Up @@ -1720,7 +1720,7 @@ mod tests {
seek_count: 9, // todo: verify this
storage_cost: StorageCost {
added_bytes: 0,
replaced_bytes: 405, // todo: verify this
replaced_bytes: 409, // todo: verify this
removed_bytes: NoStorageRemoval
},
storage_loaded_bytes: 487, // todo verify this
Expand Down
6 changes: 4 additions & 2 deletions merk/src/tree/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ impl TreeNode {
let mut tree_inner: TreeNodeInner = Decode::decode(input)?;
tree_inner.kv.key = key;
if let Some(value_defined_cost_fn) = value_defined_cost_fn {
tree_inner.kv.value_defined_cost = value_defined_cost_fn(input);
tree_inner.kv.value_defined_cost =
value_defined_cost_fn(tree_inner.kv.value.as_slice());
}
self.inner = Box::new(tree_inner);
Ok(())
Expand All @@ -145,7 +146,8 @@ impl TreeNode {
let mut tree_inner: TreeNodeInner = Decode::decode(input)?;
tree_inner.kv.key = key;
if let Some(value_defined_cost_fn) = value_defined_cost_fn {
tree_inner.kv.value_defined_cost = value_defined_cost_fn(input);
tree_inner.kv.value_defined_cost =
value_defined_cost_fn(tree_inner.kv.value.as_slice());
}
Ok(TreeNode::new_with_tree_inner(tree_inner))
}
Expand Down

0 comments on commit 619f534

Please sign in to comment.