Skip to content
Permalink
Browse files

Merge pull request #743 from input-output-hk/mrBliss/fix-readers-asse…

…rtion

Fix faulty assertion in the ChainDB readers
  • Loading branch information...
mrBliss committed Jul 12, 2019
2 parents cb8c662 + 215825e commit 8456d4f3e8de3191cc660969d1e9c0d67cc9bdca
Showing with 8 additions and 7 deletions.
  1. +8 −7 ouroboros-consensus/src/Ouroboros/Storage/ChainDB/Impl/Reader.hs
@@ -466,16 +466,17 @@ switchFork ipoint newChain readerState =
-- fork won't affect it at all
ReaderInImmDB {} -> readerState
ReaderInMem rollState
| pointSlot (currentPoint rollState) > pointSlot ipoint
-- If the reader point is more recent than the interseciton point,
| pointSlot (readerRollStatePoint rollState) > pointSlot ipoint
-- If the reader point is more recent than the intersection point,
-- we have to roll back the reader to the intersection point.
-> ReaderInMem $ RollBackTo ipoint
| otherwise
-- We can keep rolling forward.
-> assert (AF.withinFragmentBounds (currentPoint rollState) newChain)
readerState
where
currentPoint = castPoint . readerRollStatePoint
-- We can keep rolling forward. Note that this does not mean the
-- reader point is still on the current fragment, as headers older
-- than @k@ might have been moved from the fragment to the
-- ImmutableDB. This will be noticed when the next instruction is
-- requested; we'll switch to the 'ReaderInImmDB' state.
-> readerState

-- | Close all open 'Reader's.
closeAllReaders

0 comments on commit 8456d4f

Please sign in to comment.
You can’t perform that action at this time.