diff --git a/zebrad/src/components/mempool/storage.rs b/zebrad/src/components/mempool/storage.rs index fed687e0..2c10a41f 100644 --- a/zebrad/src/components/mempool/storage.rs +++ b/zebrad/src/components/mempool/storage.rs @@ -1,7 +1,4 @@ -use std::{ - collections::{HashMap, HashSet, VecDeque}, - hash::Hash, -}; +use std::collections::{HashMap, HashSet, VecDeque}; use zebra_chain::{ block, @@ -106,12 +103,12 @@ impl Storage { // `retain()` removes it and returns `Some(UnminedTx)`. If it's not // present and nothing changes, returns `None`. - return match self.verified.binary_search_by_key(txid, |&tx| tx.id.hash()) { - Ok(tx) => { - self.verified.retain(|x| &x.id != txid); - Some(tx) + return match self.verified.clone().iter().find(|tx| &tx.id == txid) { + Some(tx) => { + self.verified.retain(|tx| &tx.id != txid); + Some(tx.clone()) } - Err(e) => None, + None => None, }; } diff --git a/zebrad/src/components/mempool/storage/tests.rs b/zebrad/src/components/mempool/storage/tests.rs index 981fb09b..5bd5b3cd 100644 --- a/zebrad/src/components/mempool/storage/tests.rs +++ b/zebrad/src/components/mempool/storage/tests.rs @@ -16,16 +16,16 @@ fn mempool_storage_crud_mainnet() { let mut storage: Storage = Default::default(); // Get transactions from the first 10 blocks of the Zcash blockchain - let (total_transactions, unmined_transactions) = unmined_transactions_in_blocks(10, network); + let (_, unmined_transactions) = unmined_transactions_in_blocks(10, network); // Get one (1) unmined transaction - let unmined_tx = unmined_transactions[0]; + let unmined_tx = &unmined_transactions[0]; // Insert unmined tx into the mempool. - storage.insert(unmined_tx); + let _ = storage.insert(unmined_tx.clone()); // Check that it is in the mempool, and not rejected. - assert!(storage.contains(&unmined_tx.id)); + assert!(storage.clone().contains(&unmined_tx.id)); // Remove tx let _ = storage.remove(&unmined_tx.id);