parent
eff4f8720c
commit
c03d1c156b
|
|
@ -1,7 +1,4 @@
|
||||||
use std::{
|
use std::collections::{HashMap, HashSet, VecDeque};
|
||||||
collections::{HashMap, HashSet, VecDeque},
|
|
||||||
hash::Hash,
|
|
||||||
};
|
|
||||||
|
|
||||||
use zebra_chain::{
|
use zebra_chain::{
|
||||||
block,
|
block,
|
||||||
|
|
@ -106,12 +103,12 @@ impl Storage {
|
||||||
// `retain()` removes it and returns `Some(UnminedTx)`. If it's not
|
// `retain()` removes it and returns `Some(UnminedTx)`. If it's not
|
||||||
// present and nothing changes, returns `None`.
|
// present and nothing changes, returns `None`.
|
||||||
|
|
||||||
return match self.verified.binary_search_by_key(txid, |&tx| tx.id.hash()) {
|
return match self.verified.clone().iter().find(|tx| &tx.id == txid) {
|
||||||
Ok(tx) => {
|
Some(tx) => {
|
||||||
self.verified.retain(|x| &x.id != txid);
|
self.verified.retain(|tx| &tx.id != txid);
|
||||||
Some(tx)
|
Some(tx.clone())
|
||||||
}
|
}
|
||||||
Err(e) => None,
|
None => None,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,16 @@ fn mempool_storage_crud_mainnet() {
|
||||||
let mut storage: Storage = Default::default();
|
let mut storage: Storage = Default::default();
|
||||||
|
|
||||||
// Get transactions from the first 10 blocks of the Zcash blockchain
|
// 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
|
// Get one (1) unmined transaction
|
||||||
let unmined_tx = unmined_transactions[0];
|
let unmined_tx = &unmined_transactions[0];
|
||||||
|
|
||||||
// Insert unmined tx into the mempool.
|
// 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.
|
// 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
|
// Remove tx
|
||||||
let _ = storage.remove(&unmined_tx.id);
|
let _ = storage.remove(&unmined_tx.id);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue