Skip to content

Commit 172dd7c

Browse files
author
drsk
committed
carry missed rounds over in rotateCapitalDistribution.
1 parent 063676c commit 172dd7c

File tree

1 file changed

+18
-4
lines changed
  • concordium-consensus/src/Concordium/GlobalState/Persistent

1 file changed

+18
-4
lines changed

concordium-consensus/src/Concordium/GlobalState/Persistent/PoolRewards.hs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Concordium.GlobalState.Persistent.PoolRewards (
2121
) where
2222

2323
import Control.Exception (assert)
24+
import Data.Bool.Singletons
2425
import qualified Data.Map.Strict as Map
2526
import Data.Serialize
2627
import qualified Data.Vector as Vec
@@ -277,17 +278,30 @@ bakerBlockCounts PoolRewards{..} = do
277278
-- | Rotate the capital distribution, so that the current capital distribution is replaced by the
278279
-- next one, and set up empty pool rewards.
279280
rotateCapitalDistribution ::
281+
forall av ref m bhv.
280282
(MonadBlobStore m, Reference m ref (PoolRewards bhv av), IsBlockHashVersion bhv, IsAccountVersion av) =>
281283
ref (PoolRewards bhv av) ->
282284
m (ref (PoolRewards bhv av))
283285
rotateCapitalDistribution oldPoolRewards = do
284286
pr <- refLoad oldPoolRewards
285287
nextCap <- refLoad (nextCapital pr)
288+
oldBakerPoolRewardDetails <- LFMBT.toAscList $ bakerPoolRewardDetails pr
286289
rewardDetails <-
287-
LFMBT.fromAscList $
288-
replicate
289-
(Vec.length (bakerPoolCapital nextCap))
290-
emptyBakerPoolRewardDetails
290+
case sSupportsValidatorSuspension (accountVersion @av) of
291+
STrue -> do
292+
LFMBT.fromAscList $
293+
-- Carry over the old missed rounds
294+
[ (emptyBakerPoolRewardDetails @av){missedRounds = missedRounds bprd}
295+
| bprd <- oldBakerPoolRewardDetails
296+
]
297+
++ replicate
298+
(Vec.length (bakerPoolCapital nextCap) - length oldBakerPoolRewardDetails)
299+
emptyBakerPoolRewardDetails
300+
SFalse ->
301+
LFMBT.fromAscList $
302+
replicate
303+
(Vec.length (bakerPoolCapital nextCap))
304+
emptyBakerPoolRewardDetails
291305
refMake $
292306
pr
293307
{ currentCapital = nextCapital pr,

0 commit comments

Comments
 (0)