Skip to content

Commit

Permalink
Fix bounds in computeLoEMaxExtra
Browse files Browse the repository at this point in the history
As it was before, the code would in fact never return `Just 0`, only
`Nothing` or `Just x` with `x > 0`.
  • Loading branch information
Niols committed May 29, 2024
1 parent da907c8 commit d32239b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -811,14 +811,14 @@ chainSelectionForBlock cdb@CDB{..} blockCache hdr punish = electric $ do
computeLoEMaxExtra (LoEEnabled loeFrag) newBlockFrag =
-- Both fragments are on the same chain
if loeSuffixLength == 0 || rollback == 0 then
if rollback < k + loeSuffixLength
if rollback <= k + loeSuffixLength
then Just $ LoEEnabled $ k + loeSuffixLength - rollback
else Nothing
else
-- REVIEW: Since we filter out candidates that fork off the LoE later,
-- it does not really matter what we return here and we could just
-- return @Nothing@ or merge it in the previous case.
if rollback < k
if rollback <= k
then Just $ LoEEnabled $ k - rollback
else Nothing
where
Expand Down

0 comments on commit d32239b

Please sign in to comment.