1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2019 Conflux Foundation. All rights reserved.
// Conflux is free software and distributed under GNU General Public License.
// See http://www.gnu.org/licenses/

#[macro_use]
pub(super) mod maybe_in_place_byte_array_macro;

pub mod children_table;
pub(super) mod compressed_path;
pub(super) mod maybe_in_place_byte_array;
pub mod merkle;
pub mod mpt_cursor;
pub mod mpt_merger;
pub mod simple_mpt;
pub mod trie_node;
pub mod trie_proof;
pub(super) mod walk;

#[cfg(test)]
mod tests;

pub use self::{
    children_table::*,
    compressed_path::{
        CompressedPathRaw, CompressedPathRef, CompressedPathTrait,
    },
    mpt_merger::MptMerger,
    trie_node::{TrieNodeTrait, VanillaTrieNode},
    trie_proof::TrieProof,
};

pub type MptKeyValue = (Vec<u8>, Box<[u8]>);

/// Classes implement KVInserter is used to store key-values in MPT iteration.
pub trait KVInserter<Value> {
    fn push(&mut self, v: Value) -> Result<()>;
}

impl<Value> KVInserter<Value> for Vec<Value> {
    fn push(&mut self, v: Value) -> Result<()> { Ok((*self).push(v)) }
}

use super::errors::Result;