@@ -28,7 +28,7 @@ import qualified Cardano.Ledger.State as Ledger
2828import Cardano.Ledger.Val ((<+>) )
2929import Cardano.Prelude
3030import qualified Data.Map.Strict as Map
31- import Data.VMap (VB , VMap (.. ))
31+ import Data.VMap (VB , VMap (.. ), VS )
3232import qualified Data.VMap as VMap
3333import qualified Data.Vector.Generic as VG
3434import Lens.Micro
@@ -49,12 +49,12 @@ data StakeSliceRes
4949
5050data StakeSlice = StakeSlice
5151 { sliceEpochNo :: ! EpochNo
52- , sliceDistr :: ! ( Map StakeCred (Coin , PoolKeyHash ))
52+ , sliceDistr :: ! [( StakeCred , (Coin , PoolKeyHash ))]
5353 }
5454 deriving (Eq )
5555
5656emptySlice :: EpochNo -> StakeSlice
57- emptySlice epoch = StakeSlice epoch Map. empty
57+ emptySlice epoch = StakeSlice epoch []
5858
5959getSecurityParameter ::
6060 ConsensusProtocol (BlockProtocol blk ) =>
@@ -120,7 +120,7 @@ genericStakeSlice pInfo epochBlockNo lstate isMigration
120120 Ledger. ssStakeMark . Shelley. esSnapshots . Shelley. nesEs $
121121 Consensus. shelleyLedgerState lstate
122122
123- activeStakeEntries :: VMap. KVVector VB VB (Credential Staking , StakeWithDelegation )
123+ activeStakeEntries :: VMap. KVVector VB VS (Credential Staking , StakeWithDelegation )
124124 activeStakeEntries = VMap. unVMap $ Ledger. unActiveStake $ Ledger. ssActiveStake stakeSnapshot
125125
126126 delegationsLen :: Word64
@@ -162,13 +162,12 @@ genericStakeSlice pInfo epochBlockNo lstate isMigration
162162 , sliceDistr = distribution
163163 }
164164 where
165- activeStakeSliced :: VMap VB VB (Credential Staking ) StakeWithDelegation
165+ activeStakeSliced :: VMap VB VS (Credential Staking ) StakeWithDelegation
166166 activeStakeSliced = VMap $ VG. slice (fromIntegral index) (fromIntegral actualSize) activeStakeEntries
167167
168- distribution :: Map StakeCred (Coin , PoolKeyHash )
168+ distribution :: [( StakeCred , (Coin , PoolKeyHash ))]
169169 distribution =
170- VMap. toMap $
171- VMap. map (\ swd -> (Ledger. fromCompact (unNonZero (swdStake swd)), swdDelegation swd)) activeStakeSliced
170+ VMap. foldlWithKey (\ acc cred swd -> (cred, (Ledger. fromCompact (unNonZero (swdStake swd)), swdDelegation swd)) : acc) [] activeStakeSliced
172171
173172countEpochStake ::
174173 ExtLedgerState CardanoBlock mk ->
@@ -198,7 +197,7 @@ genericCountEpochStake lstate =
198197 Ledger. ssStakeMark . Shelley. esSnapshots . Shelley. nesEs $
199198 Consensus. shelleyLedgerState lstate
200199
201- activeStake :: VMap VB VB (Credential Staking ) StakeWithDelegation
200+ activeStake :: VMap VB VS (Credential Staking ) StakeWithDelegation
202201 activeStake = Ledger. unActiveStake $ Ledger. ssActiveStake stakeSnapshot
203202
204203 -- ActiveStake only contains entries with non-zero stake, so no filtering needed
@@ -237,7 +236,7 @@ genericFullStakeSlice lstate =
237236 Ledger. ssStakeMark . Shelley. esSnapshots . Shelley. nesEs $
238237 Consensus. shelleyLedgerState lstate
239238
240- activeStakeEntries :: VMap. KVVector VB VB (Credential Staking , StakeWithDelegation )
239+ activeStakeEntries :: VMap. KVVector VB VS (Credential Staking , StakeWithDelegation )
241240 activeStakeEntries = VMap. unVMap $ Ledger. unActiveStake $ Ledger. ssActiveStake stakeSnapshot
242241
243242 delegationsLen :: Word64
@@ -254,13 +253,12 @@ genericFullStakeSlice lstate =
254253 , sliceDistr = distribution
255254 }
256255 where
257- activeStakeSliced :: VMap VB VB (Credential Staking ) StakeWithDelegation
256+ activeStakeSliced :: VMap VB VS (Credential Staking ) StakeWithDelegation
258257 activeStakeSliced = VMap $ VG. slice (fromIntegral index) (fromIntegral delegationsLen) activeStakeEntries
259258
260- distribution :: Map StakeCred (Coin , PoolKeyHash )
259+ distribution :: [( StakeCred , (Coin , PoolKeyHash ))]
261260 distribution =
262- VMap. toMap $
263- VMap. map (\ swd -> (Ledger. fromCompact (unNonZero (swdStake swd)), swdDelegation swd)) activeStakeSliced
261+ VMap. foldlWithKey (\ acc cred swd -> (cred, (Ledger. fromCompact (unNonZero (swdStake swd)), swdDelegation swd)) : acc) [] activeStakeSliced
264262
265263getPoolDistr ::
266264 ExtLedgerState CardanoBlock mk ->
0 commit comments