Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove children hashes methods #35

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/nodes/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::{super::TrieMask, rlp_node, CHILD_INDEX_RANGE};
use alloy_primitives::{hex, B256};
use alloy_rlp::{length_of_length, Buf, BufMut, Decodable, Encodable, Header, EMPTY_STRING_CODE};
use core::{fmt, ops::Range, slice::Iter};
use nybbles::Nibbles;

#[allow(unused_imports)]
use alloc::vec::Vec;
Expand Down Expand Up @@ -164,21 +163,6 @@ impl<'a> BranchNodeRef<'a> {
.map(|(_, child)| B256::from_slice(&child[1..]))
}

/// Return an iterator over stack items and corresponding indices that match the state mask.
pub fn indexed_children(&self) -> impl Iterator<Item = (u8, B256)> + '_ {
BranchChildrenIter::new(self).map(|(index, child)| (index, B256::from_slice(&child[1..])))
}

/// Given the prefix, return an iterator over stack items that match the
/// state mask and their corresponding full paths.
pub fn prefixed_children(&self, prefix: Nibbles) -> impl Iterator<Item = (Nibbles, B256)> + '_ {
self.indexed_children().map(move |(index, hash)| {
let mut path = prefix.clone();
path.push(index);
(path, hash)
})
}

/// Returns the RLP encoding of the branch node given the state mask of children present.
pub fn rlp(&self, out: &mut Vec<u8>) -> Vec<u8> {
self.encode(out);
Expand Down
Loading