Skip to content

Commit

Permalink
remove stale mempool txs before fetching new ones (and possibly failing)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdorfman committed Mar 27, 2024
1 parent efcb76f commit b091634
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/new_index/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ impl Mempool {
.chain_err(|| "failed to update mempool from daemon")?;
let to_remove: HashSet<&Txid> = old_txids.difference(&new_txids).collect();

// 2. Remove missing transactions. Even if we are unable to download new transactions from
// the daemon, we still want to remove the transactions that are no longer in the mempool.
mempool.write().unwrap(),remove(to_remove);

// 2. Download the new transactions from the daemon's mempool
let to_add = Mempool::download_new_mempool_txs(&daemon, &old_txids, &new_txids)?;

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

mempool.count
.with_label_values(&["txs"])
Expand Down

0 comments on commit b091634

Please sign in to comment.