fn store_changes(
        &self,
        successor_root_hash: &[u8],
        batch: &[(Vec<u8>, Vec<u8>)],
        deletions: &[Vec<u8>],
    ) -> Result<(), StateDatabaseError> {
        let mut db_writer = self.db.get_writer()?;

        // We expect this to be hex, since we generated it
        let root_hash_bytes = ::hex::decode(&self.root_hash).expect("Improper hex");

        for &(ref key, ref value) in batch {
            match db_writer.put(::hex::encode(key).as_bytes(), &value) {
                Ok(_) => continue,
                Err(DatabaseError::DuplicateEntry) => {
                    increment_ref_count(&mut *db_writer, key)?;
                }
                Err(err) => return Err(StateDatabaseError::from(err)),
            }
        }

        let mut current_change_log = get_change_log(db_writer.as_reader(), &root_hash_bytes)?;
        if let Some(change_log) = current_change_log.as_mut() {
            let successor = Successor {
                successor: Vec::from(successor_root_hash),
                deletions: deletions.to_vec(),
            };
            change_log.successors.push(successor);
        }

        let next_change_log = ChangeLogEntry {
            parent: root_hash_bytes.clone(),
            additions: batch
                .iter()
                .map(|&(ref hash, _)| hash.clone())
                .collect::<Vec<Vec<u8>>>(),
            successors: vec![],
        };

        if current_change_log.is_some() {
            write_change_log(
                &mut *db_writer,
                &root_hash_bytes,
                &current_change_log.unwrap(),
            )?;
        }
        write_change_log(&mut *db_writer, successor_root_hash, &next_change_log)?;

        db_writer.commit()?;
        Ok(())
    }
/// Puts all the items into the database.
Puts all the items into the database.
Puts all the items into the database .
fn store_changes(
        &self,
        successor_root_hash: &[u8],
        batch: &[(Vec<u8>, Vec<u8>)],
        deletions: &[Vec<u8>],
    ) -> Result<(), StateDatabaseError> {
        let mut db_writer = self.db.get_writer()?;
        // We expect this to be hex, since we generated it
        let root_hash_bytes = ::hex::decode(&self.root_hash).expect("Improper hex");
        for &(ref key, ref value) in batch {
            match db_writer.put(::hex::encode(key).as_bytes(), &value) {
                Ok(_) => continue,
                Err(DatabaseError::DuplicateEntry) => {
                    increment_ref_count(&mut *db_writer, key)?;
                }
                Err(err) => return Err(StateDatabaseError::from(err)),
            }
        }
        let mut current_change_log = get_change_log(db_writer.as_reader(), &root_hash_bytes)?;
        if let Some(change_log) = current_change_log.as_mut() {
            let successor = Successor {
                successor: Vec::from(successor_root_hash),
                deletions: deletions.to_vec(),
            };
            change_log.successors.push(successor);
        }
        let next_change_log = ChangeLogEntry {
            parent: root_hash_bytes.clone(),
            additions: batch
                .iter()
                .map(|&(ref hash, _)| hash.clone())
                .collect::<Vec<Vec<u8>>>(),
            successors: vec![],
        };
        if current_change_log.is_some() {
            write_change_log(
                &mut *db_writer,
                &root_hash_bytes,
                &current_change_log.unwrap(),
            )?;
        }
        write_change_log(&mut *db_writer, successor_root_hash, &next_change_log)?;
        db_writer.commit()?;
        Ok(())
    }
fn store_changes ( & self , successor_root_hash : & [ u8 ] , batch : & [ ( Vec < u8 > , Vec < u8 > ) ] , deletions : & [ Vec < u8 > ] , ) -> Result < ( ) , StateDatabaseError > { let mut db_writer = self . db . get_writer ( ) ? ; // We expect this to be hex, since we generated it let root_hash_bytes = :: hex :: decode ( & self . root_hash ) . expect ( " " ) ; for & ( ref key , ref value ) in batch { match db_writer . put ( :: hex :: encode ( key ) . as_bytes ( ) , & value ) { Ok ( _ ) => continue , Err ( DatabaseError :: DuplicateEntry ) => { increment_ref_count ( & mut * db_writer , key ) ? ; } Err ( err ) => return Err ( StateDatabaseError :: from ( err ) ) , } } let mut current_change_log = get_change_log ( db_writer . as_reader ( ) , & root_hash_bytes ) ? ; if let Some ( change_log ) = current_change_log . as_mut ( ) { let successor = Successor { successor : Vec :: from ( successor_root_hash ) , deletions : deletions . to_vec ( ) , } ; change_log . successors . push ( successor ) ; } let next_change_log = ChangeLogEntry { parent : root_hash_bytes . clone ( ) , additions : batch . iter ( ) . map ( | & ( ref hash , _ ) | hash . clone ( ) ) . collect :: < Vec < Vec < u8 > > > ( ) , successors : vec ! [ ] , } ; if current_change_log . is_some ( ) { write_change_log ( & mut * db_writer , & root_hash_bytes , & current_change_log . unwrap ( ) , ) ? ; } write_change_log ( & mut * db_writer , successor_root_hash , & next_change_log ) ? ; db_writer . commit ( ) ? ; Ok ( ( ) ) }
Puts all the items into the database.
Puts all the items into the database .
&self
successor_root_hash
&[u8]
batch
&[(Vec<u8>, Vec<u8>)]
deletions
&[Vec<u8>]
&self
successor_root_hash
&[u8]
batch
&[(Vec<u8>, Vec<u8>)]
deletions
&[Vec<u8>]