Skip to content
Permalink
Browse files

ChainDB.Model fix bug in garbageCollectable

A block no longer in the model has most likely been garbage-collected from the
model, so it is surely garbage-collectable in the real implementation.
  • Loading branch information...
mrBliss committed Jul 11, 2019
1 parent f7a26af commit e3b31a48166f00b93aa9bfc4f71489cb72eb069c
Showing with 6 additions and 3 deletions.
  1. +6 −3 ouroboros-consensus/src/Ouroboros/Storage/ChainDB/Model.hs
@@ -421,16 +421,19 @@ garbageCollectable secParam m@Model{..} b =

-- Return 'True' when the model contains the block corresponding to the point
-- and the block itself is eligible for garbage collection, i.e. the real
-- implementation might have garbage collected it. In all other cases, return
-- 'False'.
-- implementation might have garbage collected it.
--
-- If the block is not in the model, return 'True', as it has likely been
-- garbage-collected from the model too. Note that we cannot distinguish this
-- case from a block that was never added to the model in the first place.
garbageCollectablePoint :: forall blk. HasHeader blk
=> SecurityParam -> Model blk -> Point blk -> Bool
garbageCollectablePoint secParam m@Model{..} pt
| BlockHash hash <- Block.pointHash pt
, Just blk <- getBlock hash m
= garbageCollectable secParam m blk
| otherwise
= False
= True

garbageCollect :: forall blk. HasHeader blk
=> SecurityParam -> Model blk -> Model blk

0 comments on commit e3b31a4

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