@@ -33,10 +33,9 @@ import Serokell.Util (Color (Red), colorize)
33
33
import Serokell.Util.Verify (formatAllErrors , verResToMonadError )
34
34
35
35
import Pos.Chain.Block (Block , Blund , ConsensusEraLeaders (.. ),
36
- HasSlogGState , LastBlkSlots , LastSlotInfo (.. ), MainBlock ,
36
+ HasSlogGState , LastBlkSlots , LastSlotInfo (.. ),
37
37
SlogUndo (.. ), genBlockLeaders , headerHash , headerHashG ,
38
- mainBlockLeaderKey , mainBlockSlot , prevBlockL ,
39
- verifyBlocks )
38
+ prevBlockL , blockLastSlotInfo , verifyBlocks )
40
39
import Pos.Chain.Genesis as Genesis (Config (.. ),
41
40
configBlkSecurityParam , configEpochSlots ,
42
41
configGenesisWStakeholders , configK )
@@ -45,14 +44,14 @@ import Pos.Chain.Update (BlockVersion (..), ConsensusEra (..),
45
44
ObftConsensusStrictness (.. ), UpdateConfiguration ,
46
45
lastKnownBlockVersion )
47
46
import Pos.Core (BlockCount , difficultyL , epochIndexL ,
48
- epochOrSlotToEpochIndex , flattenSlotId , kEpochSlots ,
47
+ epochOrSlotToEpochIndex , kEpochSlots ,
49
48
pcBlkSecurityParam )
50
49
import Pos.Core.Chrono (NE , NewestFirst (getNewestFirst ),
51
50
OldestFirst (.. ), toOldestFirst , _OldestFirst )
52
51
import Pos.Core.Exception (assertionFailed , reportFatalError )
53
52
import Pos.Core.NetworkMagic (NetworkMagic (.. ), makeNetworkMagic )
54
- import Pos.Core.Slotting (HasEpochIndex , MonadSlots , SlotCount ,
55
- SlotId ( .. ), getEpochOrSlot )
53
+ import Pos.Core.Slotting (HasEpochIndex , MonadSlots , SlotId ( .. ) ,
54
+ getEpochOrSlot )
56
55
import Pos.DB (SomeBatchOp (.. ))
57
56
import Pos.DB.Block.BListener (MonadBListener (.. ))
58
57
import qualified Pos.DB.Block.GState.BlockExtra as GS
@@ -221,7 +220,7 @@ slogVerifyBlocks genesisConfig curSlot blocks = runExceptT $ do
221
220
-- these slots will be added if we apply all blocks
222
221
let newSlots :: [LastSlotInfo ]
223
222
newSlots =
224
- mapMaybe (toLastSlotInfo (configEpochSlots genesisConfig)) $ toList blocks
223
+ mapMaybe (blockLastSlotInfo (configEpochSlots genesisConfig)) $ toList blocks
225
224
let combinedSlots :: LastBlkSlots
226
225
combinedSlots = lastSlots & _Wrapped %~ (<> newSlots)
227
226
-- these slots will be removed if we apply all blocks, because we store
@@ -246,16 +245,6 @@ slogVerifyBlocks genesisConfig curSlot blocks = runExceptT $ do
246
245
-- 'slogUndo' is the same as the size of 'blocks'.
247
246
return $ over _Wrapped NE. fromList $ map (SlogUndo . fmap lsiFlatSlotId) slogUndo
248
247
249
- toLastSlotInfo :: SlotCount -> Block -> Maybe LastSlotInfo
250
- toLastSlotInfo slotCount blk =
251
- convert <$> rightToMaybe blk
252
- where
253
- convert :: MainBlock -> LastSlotInfo
254
- convert b =
255
- LastSlotInfo
256
- (flattenSlotId slotCount $ view mainBlockSlot b)
257
- (view mainBlockLeaderKey b)
258
-
259
248
-- | Set of constraints necessary to apply/rollback blocks in Slog.
260
249
type MonadSlogApply ctx m =
261
250
( MonadSlogBase ctx m
@@ -328,7 +317,7 @@ slogApplyBlocks nm k (ShouldCallBListener callBListener) blunds = do
328
317
fmap (GS. SetInMainChain True . view headerHashG . fst ) blunds
329
318
330
319
newSlots :: [LastSlotInfo ]
331
- newSlots = mapMaybe (toLastSlotInfo (kEpochSlots k)) $ toList blocks
320
+ newSlots = mapMaybe (blockLastSlotInfo (kEpochSlots k)) $ toList blocks
332
321
333
322
newLastSlots :: LastBlkSlots -> LastBlkSlots
334
323
newLastSlots = OldestFirst . updateLastSlots . getOldestFirst
@@ -417,7 +406,7 @@ slogRollbackBlocks genesisConfig (BypassSecurityCheck bypassSecurity) (ShouldCal
417
406
418
407
lastSlotsToAppend :: [LastSlotInfo ]
419
408
lastSlotsToAppend =
420
- mapMaybe (toLastSlotInfo (configEpochSlots genesisConfig) . fst )
409
+ mapMaybe (blockLastSlotInfo (configEpochSlots genesisConfig) . fst )
421
410
$ toList (toOldestFirst blunds)
422
411
423
412
newLastSlots :: LastBlkSlots -> LastBlkSlots
0 commit comments