MCPcopy Create free account
hub / github.com/base/base / unblind

Method unblind

crates/proof/mpt/src/node.rs:125–138  ·  view source on GitHub ↗

Unblinds the [`TrieNode`] if it is a [`TrieNode::Blinded`] node.

(&mut self, fetcher: &F)

Source from the content-addressed store, hash-verified

123
124 /// Unblinds the [`TrieNode`] if it is a [`TrieNode::Blinded`] node.
125 pub fn unblind<F: TrieProvider>(&mut self, fetcher: &F) -> TrieNodeResult<()> {
126 if let Self::Blinded { commitment } = self {
127 if *commitment == EMPTY_ROOT_HASH {
128 // If the commitment is the empty root hash, the node is empty, and we don't need to
129 // reach out to the fetcher.
130 *self = Self::Empty;
131 } else {
132 *self = fetcher
133 .trie_node_by_hash(*commitment)
134 .map_err(|e| TrieNodeError::Provider(e.to_string()))?;
135 }
136 }
137 Ok(())
138 }
139
140 /// Walks down the trie to a leaf value with the given key, if it exists. Preimages for blinded
141 /// nodes along the path are fetched using the `fetcher` function, and persisted in the inner

Callers 4

openMethod · 0.80
insertMethod · 0.80
deleteMethod · 0.80
collapse_if_possibleMethod · 0.80

Calls 1

trie_node_by_hashMethod · 0.45

Tested by

no test coverage detected