MCPcopy Create free account
hub / github.com/base/triedb / new_leaf

Method new_leaf

src/node.rs:82–97  ·  view source on GitHub ↗

Creates a new account leaf or storage leaf [Node] from a [Nibbles] prefix and a [TrieValue]. # Panics This function will panic if the provided prefix is greater than 64 nibbles long.

(prefix: &RawPath, value: &TrieValue)

Source from the content-addressed store, hash-verified

80 ///
81 /// This function will panic if the provided prefix is greater than 64 nibbles long.
82 pub fn new_leaf(prefix: &RawPath, value: &TrieValue) -> Result<Self, NodeError> {
83 let prefix = prefix.try_into().map_err(|_| NodeError::MaxPrefixLengthExceeded)?;
84
85 match value {
86 TrieValue::Account(account) => Ok(Self::new_account_leaf(
87 prefix,
88 encode_fixed_size(&account.balance),
89 encode_fixed_size(&account.nonce),
90 account.code_hash,
91 None,
92 )),
93 TrieValue::Storage(storage) => {
94 Ok(Self::new_storage_leaf(prefix, encode_fixed_size(storage)))
95 }
96 }
97 }
98
99 fn new_account_leaf(
100 prefix: Nibbles,

Callers

nothing calls this directly

Calls 1

try_intoMethod · 0.80

Tested by

no test coverage detected