Skip to content

Commit

Permalink
Only reset the mempool in handle_new_tip if in ibd
Browse files Browse the repository at this point in the history
  • Loading branch information
ImplOfAnImpl committed Jan 26, 2024
1 parent f7f9adc commit 7c23c17
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mempool/src/pool/reorg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,17 @@ pub fn handle_new_tip<M: MemoryUsageEstimator>(
if is_ibd || new_tip != actual_tip {
log::debug!("Not updating mempool: is_ibd = {is_ibd}, new_tip = {new_tip:?}, actual_tip = {actual_tip:?}");

// We still need to update the current tx_verifier tip
let mut old_transactions = mempool.reset();
if old_transactions.next().is_some() {
log::warn!("Discarding mempool transactions during IBD or because the tip has changed");
if is_ibd {
// Note: mempool.reset() will also re-create the tx verifier from the current chainstate,
// which will also change its "best block for utxos". This is not really needed here,
// but some existing functional tests, namely blockprod_ibd.py and mempool_ibd.py,
// use this fact to detect that the corresponding new tip event has already reached
// the mempool. TODO: refactor the tests, remove this call of "mempool.reset()".
let mut old_transactions = mempool.reset();
if old_transactions.next().is_some() {
// Note: actually, this should never happen during ibd.
log::warn!("Discarding mempool transactions during IBD");
}
}
return Ok(());
}
Expand Down

0 comments on commit 7c23c17

Please sign in to comment.