mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(trie): make rlp_node fns pub (#13818)
This commit is contained in:
@ -645,12 +645,26 @@ impl<P> RevealedSparseTrie<P> {
|
|||||||
targets
|
targets
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rlp_node_allocate(&mut self, path: Nibbles, prefix_set: &mut PrefixSet) -> RlpNode {
|
/// Look up or calculate the RLP of the node at the given path.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// If the node at provided path does not exist.
|
||||||
|
pub fn rlp_node_allocate(&mut self, path: Nibbles, prefix_set: &mut PrefixSet) -> RlpNode {
|
||||||
let mut buffers = RlpNodeBuffers::new_with_path(path);
|
let mut buffers = RlpNodeBuffers::new_with_path(path);
|
||||||
self.rlp_node(prefix_set, &mut buffers)
|
self.rlp_node(prefix_set, &mut buffers)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rlp_node(&mut self, prefix_set: &mut PrefixSet, buffers: &mut RlpNodeBuffers) -> RlpNode {
|
/// Look up or calculate the RLP of the node at the given path specified in [`RlpNodeBuffers`].
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// If the node at provided path does not exist.
|
||||||
|
pub fn rlp_node(
|
||||||
|
&mut self,
|
||||||
|
prefix_set: &mut PrefixSet,
|
||||||
|
buffers: &mut RlpNodeBuffers,
|
||||||
|
) -> RlpNode {
|
||||||
'main: while let Some((path, mut is_in_prefix_set)) = buffers.path_stack.pop() {
|
'main: while let Some((path, mut is_in_prefix_set)) = buffers.path_stack.pop() {
|
||||||
// Check if the path is in the prefix set.
|
// Check if the path is in the prefix set.
|
||||||
// First, check the cached value. If it's `None`, then check the prefix set, and update
|
// First, check the cached value. If it's `None`, then check the prefix set, and update
|
||||||
@ -1338,7 +1352,7 @@ struct RemovedSparseNode {
|
|||||||
|
|
||||||
/// Collection of reusable buffers for [`RevealedSparseTrie::rlp_node`].
|
/// Collection of reusable buffers for [`RevealedSparseTrie::rlp_node`].
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct RlpNodeBuffers {
|
pub struct RlpNodeBuffers {
|
||||||
/// Stack of paths we need rlp nodes for and whether the path is in the prefix set.
|
/// Stack of paths we need rlp nodes for and whether the path is in the prefix set.
|
||||||
path_stack: Vec<(Nibbles, Option<bool>)>,
|
path_stack: Vec<(Nibbles, Option<bool>)>,
|
||||||
/// Stack of rlp nodes
|
/// Stack of rlp nodes
|
||||||
|
|||||||
Reference in New Issue
Block a user