fn apply_db_transaction(&mut self, txn: &DbTransaction) -> Result<(), ChainStorageError> {
        let write_txn =
            WriteTransaction::new(self.env.clone()).map_err(|e| ChainStorageError::AccessError(e.to_string()))?;
        for op in txn.operations.iter() {
            trace!(target: LOG_TARGET, "[apply_db_transaction] WriteOperation: {}", op);
            match op {
                WriteOperation::Insert(insert) => self.op_insert(&write_txn, insert)?,
                WriteOperation::Delete(delete) => self.op_delete(&write_txn, delete)?,
                WriteOperation::Spend(key) => self.op_spend(&write_txn, key)?,
                WriteOperation::UnSpend(key) => self.op_unspend(&write_txn, key)?,
                _ => {},
            }
        }
        write_txn
            .commit()
            .map_err(|e| ChainStorageError::AccessError(e.to_string()))?;

        if self.is_mem_metadata_dirty {
            self.mem_metadata = fetch_metadata(&self.env, &self.metadata_db)?;
            self.is_mem_metadata_dirty = false;
        }
        Ok(())
    }
// Perform all the storage txns and all MMR transactions excluding CreateMmrCheckpoint and RewindMmr on the
// header_mmr, utxo_mmr, range_proof_mmr and kernel_mmr. Only when all the txns can successfully be applied is the
// changes committed to the backend databases. CreateMmrCheckpoint and RewindMmr txns will be performed after these
// txns have been successfully applied.
Perform all the storage txns and all MMR transactions excluding CreateMmrCheckpoint and RewindMmr on the
header_mmr, utxo_mmr, range_proof_mmr and kernel_mmr. Only when all the txns can successfully be applied is the
changes committed to the backend databases. CreateMmrCheckpoint and RewindMmr txns will be performed after these
txns have been successfully applied.
Perform all the storage txns and all MMR transactions excluding CreateMmrCheckpoint and RewindMmr on the header_mmr utxo_mmr range_proof_mmr and kernel_mmr . Only when all the txns can successfully be applied is the changes committed to the backend databases . CreateMmrCheckpoint and RewindMmr txns will be performed after these txns have been successfully applied .
fn apply_db_transaction(&mut self, txn: &DbTransaction) -> Result<(), ChainStorageError> {
        let write_txn =
            WriteTransaction::new(self.env.clone()).map_err(|e| ChainStorageError::AccessError(e.to_string()))?;
        for op in txn.operations.iter() {
            trace!(target: LOG_TARGET, "[apply_db_transaction] WriteOperation: {}", op);
            match op {
                WriteOperation::Insert(insert) => self.op_insert(&write_txn, insert)?,
                WriteOperation::Delete(delete) => self.op_delete(&write_txn, delete)?,
                WriteOperation::Spend(key) => self.op_spend(&write_txn, key)?,
                WriteOperation::UnSpend(key) => self.op_unspend(&write_txn, key)?,
                _ => {},
            }
        }
        write_txn
            .commit()
            .map_err(|e| ChainStorageError::AccessError(e.to_string()))?;
        if self.is_mem_metadata_dirty {
            self.mem_metadata = fetch_metadata(&self.env, &self.metadata_db)?;
            self.is_mem_metadata_dirty = false;
        }
        Ok(())
    }
fn apply_db_transaction ( & mut self , txn : & DbTransaction ) -> Result < ( ) , ChainStorageError > { let write_txn = WriteTransaction :: new ( self . env . clone ( ) ) . map_err ( | e | ChainStorageError :: AccessError ( e . to_string ( ) ) ) ? ; for op in txn . operations . iter ( ) { trace ! ( target LOG_TARGET " " op ) ; match op { WriteOperation :: Insert ( insert ) => self . op_insert ( & write_txn , insert ) ? , WriteOperation :: Delete ( delete ) => self . op_delete ( & write_txn , delete ) ? , WriteOperation :: Spend ( key ) => self . op_spend ( & write_txn , key ) ? , WriteOperation :: UnSpend ( key ) => self . op_unspend ( & write_txn , key ) ? , _ => { } , } } write_txn . commit ( ) . map_err ( | e | ChainStorageError :: AccessError ( e . to_string ( ) ) ) ? ; if self . is_mem_metadata_dirty { self . mem_metadata = fetch_metadata ( & self . env , & self . metadata_db ) ? ; self . is_mem_metadata_dirty = false ; } Ok ( ( ) ) }
Perform all the storage txns and all MMR transactions excluding CreateMmrCheckpoint and RewindMmr on the
header_mmr, utxo_mmr, range_proof_mmr and kernel_mmr.
Perform all the storage txns and all MMR transactions excluding CreateMmrCheckpoint and RewindMmr on the header_mmr utxo_mmr range_proof_mmr and kernel_mmr .
&mut self
txn
&DbTransaction
&mut self
txn
&DbTransaction