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: TrieMask
The 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: TrieMask
The 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: TrieMask
The 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 moreSource§impl Debug for BranchNodeCompact
impl Debug for BranchNodeCompact
Source§impl Default for BranchNodeCompact
impl Default for BranchNodeCompact
Source§fn default() -> BranchNodeCompact
fn default() -> BranchNodeCompact
Source§impl<'de> Deserialize<'de> for BranchNodeCompact
impl<'de> Deserialize<'de> for BranchNodeCompact
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for BranchNodeCompact
impl Ord for BranchNodeCompact
Source§fn cmp(&self, other: &BranchNodeCompact) -> Ordering
fn cmp(&self, other: &BranchNodeCompact) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for BranchNodeCompact
impl PartialEq for BranchNodeCompact
Source§impl PartialOrd for BranchNodeCompact
impl PartialOrd for BranchNodeCompact
Source§impl Serialize for BranchNodeCompact
impl Serialize for BranchNodeCompact
impl Eq for BranchNodeCompact
impl StructuralPartialEq for BranchNodeCompact
Auto Trait Implementations§
impl Freeze for BranchNodeCompact
impl RefUnwindSafe for BranchNodeCompact
impl Send for BranchNodeCompact
impl Sync for BranchNodeCompact
impl Unpin for BranchNodeCompact
impl UnwindSafe for BranchNodeCompact
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.