Skip to content

Commit a9b2d6b

Browse files
committed
Ensure mempool only open forkers when actually revalidating
1 parent 4bd24d0 commit a9b2d6b

File tree

1 file changed

+17
-17
lines changed
  • ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool

1 file changed

+17
-17
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -413,23 +413,23 @@ implSyncWithLedger mpEnv =
413413
-- state didn't change.
414414
withTMVarAnd istate (const $ getCurrentLedgerState ldgrInterface registry) $
415415
\is (MempoolLedgerDBView ls meFrk) -> do
416-
eFrk <- meFrk
417-
case eFrk of
418-
-- This case should happen only if the tip has moved again, this time
419-
-- to a separate fork, since the background thread saw a change in the
420-
-- tip, which should happen very rarely
421-
Left{} -> do
422-
traceWith trcr TraceMempoolTipMovedBetweenSTMBlocks
423-
pure (Nothing, is)
424-
Right frk -> do
425-
let (slot, ls') = tickLedgerState cfg $ ForgeInUnknownSlot ls
426-
if pointHash (isTip is) == castHash (getTipHash ls) && isSlotNo is == slot
427-
then do
428-
-- The tip didn't change, put the same state.
429-
traceWith trcr $ TraceMempoolSyncNotNeeded (isTip is)
430-
pure (Just (snapshotFromIS is), is)
431-
else do
432-
-- The tip changed, we have to revalidate
416+
let (slot, ls') = tickLedgerState cfg $ ForgeInUnknownSlot ls
417+
if pointHash (isTip is) == castHash (getTipHash ls) && isSlotNo is == slot
418+
then do
419+
-- The tip didn't change, put the same state.
420+
traceWith trcr $ TraceMempoolSyncNotNeeded (isTip is)
421+
pure (Just (snapshotFromIS is), is)
422+
else do
423+
-- The tip changed, we have to revalidate
424+
eFrk <- meFrk
425+
case eFrk of
426+
-- This case should happen only if the tip has moved again, this time
427+
-- to a separate fork, since the background thread saw a change in the
428+
-- tip, which should happen very rarely
429+
Left{} -> do
430+
traceWith trcr TraceMempoolTipMovedBetweenSTMBlocks
431+
pure (Nothing, is)
432+
Right frk -> do
433433
modifyMVar_
434434
forkerMVar
435435
( \oldFrk -> do

0 commit comments

Comments
 (0)