Skip to content

Commit a0ff028

Browse files
committed
remove stale mempool txs before fetching new ones (and possibly failing)
1 parent ac3425d commit a0ff028

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/new_index/mempool.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ impl Mempool {
499499
.chain_err(|| "failed to update mempool from daemon")?;
500500
let to_remove: HashSet<&Txid> = old_txids.difference(&new_txids).collect();
501501

502+
// 2. Remove missing transactions. Even if we are unable to download new transactions from
503+
// the daemon, we still want to remove the transactions that are no longer in the mempool.
504+
mempool.write().unwrap().remove(to_remove);
505+
502506
// 2. Download the new transactions from the daemon's mempool
503507
let txids: Vec<&Txid> = new_txids.difference(&old_txids).collect();
504508
let to_add = daemon
@@ -510,8 +514,6 @@ impl Mempool {
510514
let mut mempool = mempool.write().unwrap();
511515
// Add new transactions
512516
mempool.add(to_add);
513-
// Remove missing transactions
514-
mempool.remove(to_remove);
515517

516518
mempool
517519
.count

0 commit comments

Comments
 (0)