@@ -332,29 +332,29 @@ chainSelSync ::
332
332
-- We run a background thread that polls the candidate fragments and sends
333
333
-- 'ChainSelReprocessLoEBlocks' whenever we receive a new header or lose a
334
334
-- peer.
335
- -- If 'cdbLoE' is 'LoEDisabled', this task is skipped.
335
+ --
336
+ -- Note that we do this even when we are caught-up, as we might want to select
337
+ -- blocks that were originally postponed by the LoE, but can be adopted once we
338
+ -- conclude that we are caught-up (and hence are longer bound by the LoE).
336
339
chainSelSync cdb@ CDB {.. } (ChainSelReprocessLoEBlocks varProcessed) = do
337
- lift cdbLoE >>= \ case
338
- LoEDisabled -> pure ()
339
- LoEEnabled _ -> do
340
- (succsOf, chain) <- lift $ atomically $ do
341
- invalid <- forgetFingerprint <$> readTVar cdbInvalid
342
- (,)
343
- <$> (ignoreInvalidSuc cdbVolatileDB invalid <$>
344
- VolatileDB. filterByPredecessor cdbVolatileDB)
345
- <*> Query. getCurrentChain cdb
346
- let
347
- succsOf' = Set. toList . succsOf . pointHash . castPoint
348
- loeHashes = succsOf' (AF. anchorPoint chain)
349
- firstHeader = either (const Nothing ) Just $ AF. last chain
350
- -- We avoid the VolatileDB for the headers we already have in the chain
351
- getHeaderFromHash hash =
352
- case firstHeader of
353
- Just header | headerHash header == hash -> pure header
354
- _ -> VolatileDB. getKnownBlockComponent cdbVolatileDB GetHeader hash
355
- loeHeaders <- lift (mapM getHeaderFromHash loeHashes)
356
- for_ loeHeaders $ \ hdr ->
357
- chainSelectionForBlock cdb BlockCache. empty hdr noPunishment
340
+ (succsOf, chain) <- lift $ atomically $ do
341
+ invalid <- forgetFingerprint <$> readTVar cdbInvalid
342
+ (,)
343
+ <$> (ignoreInvalidSuc cdbVolatileDB invalid <$>
344
+ VolatileDB. filterByPredecessor cdbVolatileDB)
345
+ <*> Query. getCurrentChain cdb
346
+ let
347
+ succsOf' = Set. toList . succsOf . pointHash . castPoint
348
+ loeHashes = succsOf' (AF. anchorPoint chain)
349
+ firstHeader = either (const Nothing ) Just $ AF. last chain
350
+ -- We avoid the VolatileDB for the headers we already have in the chain
351
+ getHeaderFromHash hash =
352
+ case firstHeader of
353
+ Just header | headerHash header == hash -> pure header
354
+ _ -> VolatileDB. getKnownBlockComponent cdbVolatileDB GetHeader hash
355
+ loeHeaders <- lift (mapM getHeaderFromHash loeHashes)
356
+ for_ loeHeaders $ \ hdr ->
357
+ chainSelectionForBlock cdb BlockCache. empty hdr noPunishment
358
358
lift $ atomically $ putTMVar varProcessed ()
359
359
360
360
chainSelSync cdb@ CDB {.. } (ChainSelAddBlock BlockToAdd { blockToAdd = b, .. }) = do
0 commit comments