Function trie_db::decode_compact

source ·
pub fn decode_compact<L, DB>(
    db: &mut DB,
    encoded: &[Vec<u8>]
) -> Result<(TrieHash<L>, usize), TrieHash<L>, CError<L>>where
    L: TrieLayout,
    DB: HashDB<L::Hash, DBValue>,
Expand description

Reconstructs a partial trie DB from a compact representation. The encoding is a vector of mutated trie nodes with those child references omitted. The decode function reads them in order from the given slice, reconstructing the full nodes and inserting them into the given HashDB. It stops after fully constructing one partial trie and returns the root hash and the number of nodes read. If an error occurs during decoding, there are no guarantees about which entries were or were not added to the DB.

The number of nodes read may be fewer than the total number of items in encoded. This allows one to concatenate multiple compact encodings together and still reconstruct them all. This function makes the assumption that all child references in an inline trie node are inline references.