pub fn build(
        buf: &'a mut [Pair],
        kv_pairs: KVPairVecReader,
        proof: &'a [u8],
        account_count: u32,
        current_root: Option<H256>,
    ) -> Result<KVState<'a>, Error> {
        let mut tree = Tree::new(buf);
        for pair in kv_pairs.iter() {
            tree.update(&pair.k().unpack(), &pair.v().unpack())
                .map_err(|err| {
                    debug!("[kv state] build: update key error: {}", err);
                    Error::SMTKeyMissing
                })?;
        }
        Ok(KVState {
            tree: RefCell::new(tree),
            proof,
            account_count,
            previous_root: current_root,
        })
    }
/// params:
/// - kv_pairs, the kv pairs
/// - proof, the merkle proof of kv_pairs
/// - account count, account count in the current state
/// - current_root, calculate_root returns this value if the kv_paris & proof is empty
kv_pairs, the kv pairs
proof, the merkle proof of kv_pairs
account count, account count in the current state
current_root, calculate_root returns this value if the kv_paris & proof is empty
kv_pairs the kv pairs proof the merkle proof of kv_pairs account count account count in the current state current_root calculate_root returns this value if the kv_paris & proof is empty
pub fn build(
        buf: &'a mut [Pair],
        kv_pairs: KVPairVecReader,
        proof: &'a [u8],
        account_count: u32,
        current_root: Option<H256>,
    ) -> Result<KVState<'a>, Error> {
        let mut tree = Tree::new(buf);
        for pair in kv_pairs.iter() {
            tree.update(&pair.k().unpack(), &pair.v().unpack())
                .map_err(|err| {
                    debug!("[kv state] build: update key error: {}", err);
                    Error::SMTKeyMissing
                })?;
        }
        Ok(KVState {
            tree: RefCell::new(tree),
            proof,
            account_count,
            previous_root: current_root,
        })
    }
pub fn build ( buf : & ' a mut [ Pair ] , kv_pairs : KVPairVecReader , proof : & ' a [ u8 ] , account_count : u32 , current_root : Option < H256 > , ) -> Result < KVState < ' a > , Error > { let mut tree = Tree :: new ( buf ) ; for pair in kv_pairs . iter ( ) { tree . update ( & pair . k ( ) . unpack ( ) , & pair . v ( ) . unpack ( ) ) . map_err ( | err | { debug ! ( " " err ) ; Error :: SMTKeyMissing } ) ? ; } Ok ( KVState { tree : RefCell :: new ( tree ) , proof , account_count , previous_root : current_root , } ) }
params:
 kv_pairs, the kv pairs
 proof, the merkle proof of kv_pairs
 account count, account count in the current state
 current_root, calculate_root returns this value if the kv_paris & proof is empty
params : kv_pairs the kv pairs proof the merkle proof of kv_pairs account count account count in the current state current_root calculate_root returns this value if the kv_paris & proof is empty
buf
&'a mut [Pair]
kv_pairs
KVPairVecReader
proof
&'a [u8]
account_count
u32
current_root
Option<H256>
buf
&'a mut [Pair]
kv_pairs
KVPairVecReader
proof
&'a [u8]
account_count
u32
current_root
Option<H256>