pub fn insert<D: DatabaseHandle>(
    root: H256, database: &D, key: &[u8], value: &[u8]
) -> (H256, Change) {
    let mut change = Change::default();
    let nibble = nibble::from_key(key);

    let (new, subchange) = if root == empty_trie_hash!() {
        insert::insert_by_empty(nibble, value)
    } else {
        let old = MerkleNode::decode(&Rlp::new(database.get(root)));
        change.remove_raw(root);
        insert::insert_by_node(old, nibble, value, database)
    };
    change.merge(&subchange);
    change.add_node(&new);

    let hash = H256::from(Keccak256::digest(&rlp::encode(&new).to_vec()).as_slice());
    (hash, change)
}
/// Insert to a merkle trie. Return the new root hash and the changes.
Insert to a merkle trie. Return the new root hash and the changes.
Insert to a merkle trie . Return the new root hash and the changes .
pub fn insert<D: DatabaseHandle>(
    root: H256, database: &D, key: &[u8], value: &[u8]
) -> (H256, Change) {
    let mut change = Change::default();
    let nibble = nibble::from_key(key);
    let (new, subchange) = if root == empty_trie_hash!() {
        insert::insert_by_empty(nibble, value)
    } else {
        let old = MerkleNode::decode(&Rlp::new(database.get(root)));
        change.remove_raw(root);
        insert::insert_by_node(old, nibble, value, database)
    };
    change.merge(&subchange);
    change.add_node(&new);
    let hash = H256::from(Keccak256::digest(&rlp::encode(&new).to_vec()).as_slice());
    (hash, change)
}
pub fn insert < D : DatabaseHandle > ( root : H256 , database : & D , key : & [ u8 ] , value : & [ u8 ] ) -> ( H256 , Change ) { let mut change = Change :: default ( ) ; let nibble = nibble :: from_key ( key ) ; let ( new , subchange ) = if root == empty_trie_hash ! ( ) { insert :: insert_by_empty ( nibble , value ) } else { let old = MerkleNode :: decode ( & Rlp :: new ( database . get ( root ) ) ) ; change . remove_raw ( root ) ; insert :: insert_by_node ( old , nibble , value , database ) } ; change . merge ( & subchange ) ; change . add_node ( & new ) ; let hash = H256 :: from ( Keccak256 :: digest ( & rlp :: encode ( & new ) . to_vec ( ) ) . as_slice ( ) ) ; ( hash , change ) }
Insert to a merkle trie.
Insert to a merkle trie .
root
H256
database
&D
key
&[u8]
value
&[u8]