Skip to content

Commit

Permalink
Only get the successors of the immutable tip when reprocessing chain …
Browse files Browse the repository at this point in the history
…sel for LoE
  • Loading branch information
facundominguez committed May 30, 2024
1 parent ab0da06 commit 2acc4b3
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,16 @@ chainSelSync cdb@CDB{..} ChainSelReprocessLoEBlocks = lift cdbLoE >>= \case
<*> Query.getCurrentChain cdb
let
succsOf' = Set.toList . succsOf . pointHash . castPoint
chainPoints = AF.anchorPoint chain : (blockPoint <$> AF.toOldestFirst chain)
loeHashes = succsOf' =<< chainPoints
loeHeaders <- lift (mapM (VolatileDB.getKnownBlockComponent cdbVolatileDB GetHeader) loeHashes)
loeHashes = succsOf' (AF.anchorPoint chain)
firstHeader = either (const Nothing) Just $ AF.last chain
-- We avoid the VolatileDB for the headers we already have in the chain
getHeaderFromHash hash =
case firstHeader of
Just header | headerHash header == hash -> pure header
_ -> VolatileDB.getKnownBlockComponent cdbVolatileDB GetHeader hash
loeHeaders <- lift (mapM getHeaderFromHash loeHashes)
for_ loeHeaders $ \hdr ->
unless (AF.withinFragmentBounds (blockPoint hdr) chain) $ do
void (chainSelectionForBlock cdb BlockCache.empty hdr noPunishment)
void (chainSelectionForBlock cdb BlockCache.empty hdr noPunishment)

chainSelSync cdb@CDB {..} (ChainSelAddBlock BlockToAdd { blockToAdd = b, .. }) = do
(isMember, invalid, curChain) <- lift $ atomically $ (,,)
Expand Down

0 comments on commit 2acc4b3

Please sign in to comment.