Skip to content

Commit b091634

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

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
@@ -510,6 +510,10 @@ impl Mempool {
510510
.chain_err(|| "failed to update mempool from daemon")?;
511511
let to_remove: HashSet<&Txid> = old_txids.difference(&new_txids).collect();
512512

513+
// 2. Remove missing transactions. Even if we are unable to download new transactions from
514+
// the daemon, we still want to remove the transactions that are no longer in the mempool.
515+
mempool.write().unwrap(),remove(to_remove);
516+
513517
// 2. Download the new transactions from the daemon's mempool
514518
let to_add = Mempool::download_new_mempool_txs(&daemon, &old_txids, &new_txids)?;
515519

@@ -518,8 +522,6 @@ impl Mempool {
518522
let mut mempool = mempool.write().unwrap();
519523
// Add new transactions
520524
mempool.add(to_add);
521-
// Remove missing transactions
522-
mempool.remove(to_remove);
523525

524526
mempool.count
525527
.with_label_values(&["txs"])

0 commit comments

Comments
 (0)