pub struct BranchNodeCompact {
pub state_mask: TrieMask,
pub tree_mask: TrieMask,
pub hash_mask: TrieMask,
pub hashes: Vec<B256>,
pub root_hash: Option<B256>,
}Expand description
A struct representing a branch node in an Ethereum trie.
A branch node can have up to 16 children, each corresponding to one of the possible nibble
values (0 to f) in the trie’s path.
The masks in a BranchNode are used to efficiently represent and manage information about the
presence and types of its children. They are bitmasks, where each bit corresponds to a nibble
(half-byte, or 4 bits) value from 0 to f.
Fields§
§state_mask: TrieMaskThe bitmask indicating the presence of children at the respective nibble positions in the trie. If the bit at position i (counting from the right) is set (1), it indicates that a child exists for the nibble value i. If the bit is unset (0), it means there is no child for that nibble value.
tree_mask: TrieMaskThe bitmask representing the children at the respective nibble positions in the trie that
are also stored in the database. If the bit at position i (counting from the right)
is set (1) and also present in the state_mask, it indicates that the corresponding
child at the nibble value i is stored in the database. If the bit is unset (0), it means
the child is not stored in the database.
hash_mask: TrieMaskThe bitmask representing the hashed branch children nodes at the respective nibble
positions in the trie. If the bit at position i (counting from the right) is set (1)
and also present in the state_mask, it indicates that the corresponding child at the
nibble value i is a hashed branch child node. If the bit is unset (0), it means the child
is not a hashed branch child node.
hashes: Vec<B256>Collection of hashes associated with the children of the branch node. Each child hash is calculated by hashing two consecutive sub-branch roots.
root_hash: Option<B256>An optional root hash of the subtree rooted at this branch node.
Implementations§
Source§impl BranchNodeCompact
impl BranchNodeCompact
Sourcepub fn new(
state_mask: impl Into<TrieMask>,
tree_mask: impl Into<TrieMask>,
hash_mask: impl Into<TrieMask>,
hashes: Vec<B256>,
root_hash: Option<B256>,
) -> Self
pub fn new( state_mask: impl Into<TrieMask>, tree_mask: impl Into<TrieMask>, hash_mask: impl Into<TrieMask>, hashes: Vec<B256>, root_hash: Option<B256>, ) -> Self
Creates a new BranchNodeCompact from the given parameters.
Sourcepub fn hash_for_nibble(&self, nibble: u8) -> B256
pub fn hash_for_nibble(&self, nibble: u8) -> B256
Returns the hash associated with the given nibble.
Trait Implementations§
Source§impl Clone for BranchNodeCompact
impl Clone for BranchNodeCompact
Source§fn clone(&self) -> BranchNodeCompact
fn clone(&self) -> BranchNodeCompact
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more