pub struct BranchNode {
pub choices: [NodeRef; 16],
pub value: ValueRLP,
}Expand description
Branch Node of an an Ethereum Compatible Patricia Merkle Trie Contains the node’s value and the hash of its children nodes
Fields§
§choices: [NodeRef; 16]§value: ValueRLPImplementations§
Source§impl BranchNode
impl BranchNode
Sourcepub const EMPTY_CHOICES: [NodeRef; 16]
pub const EMPTY_CHOICES: [NodeRef; 16]
Empty choice array for more convenient node-building
Sourcepub fn new(choices: [NodeRef; 16]) -> Self
pub fn new(choices: [NodeRef; 16]) -> Self
Creates a new branch node given its children, without any stored value
Sourcepub const fn new_with_value(choices: [NodeRef; 16], value: ValueRLP) -> Self
pub const fn new_with_value(choices: [NodeRef; 16], value: ValueRLP) -> Self
Creates a new branch node given its children and value
Sourcepub fn get(
&self,
db: &dyn TrieDB,
path: Nibbles,
) -> Result<Option<ValueRLP>, TrieError>
pub fn get( &self, db: &dyn TrieDB, path: Nibbles, ) -> Result<Option<ValueRLP>, TrieError>
Retrieves a value from the subtrie originating from this node given its path
Sourcepub fn insert(
&mut self,
db: &dyn TrieDB,
path: Nibbles,
value: ValueOrHash,
) -> Result<(), TrieError>
pub fn insert( &mut self, db: &dyn TrieDB, path: Nibbles, value: ValueOrHash, ) -> Result<(), TrieError>
Inserts a value into the subtrie originating from this node
Sourcepub fn remove(
&mut self,
db: &dyn TrieDB,
path: Nibbles,
) -> Result<(Option<NodeRemoveResult>, Option<ValueRLP>), TrieError>
pub fn remove( &mut self, db: &dyn TrieDB, path: Nibbles, ) -> Result<(Option<NodeRemoveResult>, Option<ValueRLP>), TrieError>
Removes a value from the subtrie originating from this node given its path
Returns the new root of the subtrie (or a Mutated variant if the new root is self)
and the removed value if it existed in the subtrie.
Sourcepub fn compute_hash(&self, crypto: &dyn Crypto) -> NodeHash
pub fn compute_hash(&self, crypto: &dyn Crypto) -> NodeHash
Computes the node’s hash
Sourcepub fn compute_hash_no_alloc(
&self,
buf: &mut Vec<u8>,
crypto: &dyn Crypto,
) -> NodeHash
pub fn compute_hash_no_alloc( &self, buf: &mut Vec<u8>, crypto: &dyn Crypto, ) -> NodeHash
Computes the node’s hash, using the provided buffer
Sourcepub fn get_path(
&self,
db: &dyn TrieDB,
path: Nibbles,
node_path: &mut Vec<Vec<u8>>,
) -> Result<(), TrieError>
pub fn get_path( &self, db: &dyn TrieDB, path: Nibbles, node_path: &mut Vec<Vec<u8>>, ) -> Result<(), TrieError>
Traverses own subtrie until reaching the node containing path
Appends all encoded nodes traversed to node_path (including self)
Only nodes with encoded len over or equal to 32 bytes are included
Trait Implementations§
Source§impl Archive for BranchNode
impl Archive for BranchNode
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§impl Clone for BranchNode
impl Clone for BranchNode
Source§fn clone(&self) -> BranchNode
fn clone(&self) -> BranchNode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BranchNode
impl Debug for BranchNode
Source§impl Default for BranchNode
impl Default for BranchNode
Source§fn default() -> BranchNode
fn default() -> BranchNode
Source§impl<'de> Deserialize<'de> for BranchNode
impl<'de> Deserialize<'de> for BranchNode
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<__D: Fallible + ?Sized> Deserialize<BranchNode, __D> for Archived<BranchNode>
impl<__D: Fallible + ?Sized> Deserialize<BranchNode, __D> for Archived<BranchNode>
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<BranchNode, <__D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<BranchNode, <__D as Fallible>::Error>
Source§impl From<BranchNode> for Node
impl From<BranchNode> for Node
Source§fn from(val: BranchNode) -> Self
fn from(val: BranchNode) -> Self
Source§impl PartialEq for BranchNode
impl PartialEq for BranchNode
Source§fn eq(&self, other: &BranchNode) -> bool
fn eq(&self, other: &BranchNode) -> bool
self and other values to be equal, and is used by ==.Source§impl RLPEncode for BranchNode
impl RLPEncode for BranchNode
Source§impl Serialize for BranchNode
impl Serialize for BranchNode
impl StructuralPartialEq for BranchNode
Auto Trait Implementations§
impl !Freeze for BranchNode
impl RefUnwindSafe for BranchNode
impl Send for BranchNode
impl Sync for BranchNode
impl Unpin for BranchNode
impl UnsafeUnpin for BranchNode
impl UnwindSafe for BranchNode
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.