Unblinds the [`TrieNode`] if it is a [`TrieNode::Blinded`] node.
(&mut self, fetcher: &F)
| 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 |
no test coverage detected