mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
blockchain/mod.rs: minor cleanup
This commit is contained in:
@@ -271,25 +271,7 @@ impl Blockchain {
|
||||
/// Remove a given slice of pending transactions from the blockchain database.
|
||||
pub fn remove_pending_txs(&self, txs: &[Transaction]) -> Result<()> {
|
||||
let txs_hashes: Vec<TransactionHash> = txs.iter().map(|tx| tx.hash()).collect();
|
||||
let indexes = self.transactions.get_all_pending_order()?;
|
||||
// We could do indexes.iter().map(|x| txs_hashes.contains(x.1)).collect.map(|x| x.0).collect
|
||||
// but this is faster since we don't do the second iteration
|
||||
let mut removed_indexes = vec![];
|
||||
for index in indexes {
|
||||
if txs_hashes.contains(&index.1) {
|
||||
removed_indexes.push(index.0);
|
||||
}
|
||||
}
|
||||
|
||||
let txs_batch = self.transactions.remove_batch_pending(&txs_hashes);
|
||||
let txs_order_batch = self.transactions.remove_batch_pending_order(&removed_indexes);
|
||||
|
||||
// Perform an atomic transaction over the trees and apply the batches.
|
||||
let trees = [self.transactions.pending.clone(), self.transactions.pending_order.clone()];
|
||||
let batches = [txs_batch, txs_order_batch];
|
||||
self.atomic_write(&trees, &batches)?;
|
||||
|
||||
Ok(())
|
||||
self.remove_pending_txs_hashes(&txs_hashes)
|
||||
}
|
||||
|
||||
/// Remove a given slice of pending transactions hashes from the blockchain database.
|
||||
|
||||
Reference in New Issue
Block a user