Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Longarithm committed Oct 28, 2024
1 parent f9fc3ac commit 8fddc03
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/store/src/trie/mem/updating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,25 @@ impl UpdatedMemTrieNode {
impl<'a, M: ArenaMemory> GenericTrieUpdate<'a, MemTrieNodeId, FlatStateValue>
for MemTrieUpdate<'a, M>
{
/// If the ID was old, converts it to an updated one.
fn generic_ensure_updated(
&mut self,
node: GenericNodeOrIndex<MemTrieNodeId>,
) -> Result<GenericUpdatedNodeId, StorageError> {
Ok(self.ensure_updated(node))
}

/// Internal function to take a node from the array of updated nodes, setting it
/// to None. It is expected that place_node is then called to return the node to
/// the same slot.
fn generic_take_node(&mut self, index: UpdatedMemTrieNodeId) -> UpdatedMemTrieNodeWithSize {
// TODO(#12324): IMPORTANT: now, we don't compute memory usage on the
// fly for memtries. This happens in `compute_hashes_and_serialized_nodes`.
// Memory usages here are zeroed and ignored.
// However, this is fundamentally wrong because the current approach
// needs ALL children of any changed branch in memtrie. In reality, it
// is enough to have only children that are changed.
// So, we need to change `MemTrieUpdate` to store current memory usages
// and retrieve them correctly.
UpdatedMemTrieNodeWithSize { node: self.take_node(index), memory_usage: 0 }
}

/// Does the opposite of take_node; returns the node to the specified ID.
fn generic_place_node(
&mut self,
index: UpdatedMemTrieNodeId,
Expand Down

0 comments on commit 8fddc03

Please sign in to comment.