@@ -105,8 +105,9 @@ import Cardano.Api.Modes (CardanoMode, EpochSlots (..))
105
105
import qualified Cardano.Api.Modes as Api
106
106
import Cardano.Api.NetworkId (NetworkId (.. ), NetworkMagic (NetworkMagic ))
107
107
import Cardano.Api.ProtocolParameters
108
- import Cardano.Api.Query (CurrentEpochState (.. ), ProtocolState ,
109
- SerialisedCurrentEpochState (.. ), decodeCurrentEpochState , decodeProtocolState )
108
+ import Cardano.Api.Query (CurrentEpochState (.. ), PoolDistribution (unPoolDistr ), ProtocolState ,
109
+ SerialisedCurrentEpochState (.. ), SerialisedPoolDistribution ,
110
+ decodeCurrentEpochState , decodePoolDistribution , decodeProtocolState )
110
111
import Cardano.Api.Utils (textShow )
111
112
import Cardano.Binary (DecoderError , FromCBOR )
112
113
import qualified Cardano.Chain.Genesis
@@ -1385,9 +1386,10 @@ nextEpochEligibleLeadershipSlots sbe sGen serCurrEpochState ptclState poolid (Vr
1385
1386
$ obtainDecodeEpochStateConstraints sbe
1386
1387
$ decodeCurrentEpochState serCurrEpochState
1387
1388
1388
- let markSnapshotPoolDistr :: Map (SL. KeyHash 'SL.StakePool Shelley. StandardCrypto ) (SL. IndividualPoolStake Shelley. StandardCrypto )
1389
- markSnapshotPoolDistr = ShelleyAPI. unPoolDistr . ShelleyAPI. calculatePoolDistr . ShelleyAPI. _pstakeMark
1390
- $ obtainIsStandardCrypto sbe $ ShelleyAPI. esSnapshots cEstate
1389
+ let snapshot :: ShelleyAPI. SnapShot Shelley. StandardCrypto
1390
+ snapshot = ShelleyAPI. _pstakeMark $ obtainIsStandardCrypto sbe $ ShelleyAPI. esSnapshots cEstate
1391
+ markSnapshotPoolDistr :: Map (SL. KeyHash 'SL.StakePool Shelley. StandardCrypto ) (SL. IndividualPoolStake Shelley. StandardCrypto )
1392
+ markSnapshotPoolDistr = ShelleyAPI. unPoolDistr . ShelleyAPI. calculatePoolDistr $ snapshot
1391
1393
1392
1394
let slotRangeOfInterest = Set. filter
1393
1395
(not . Ledger. isOverlaySlot firstSlotOfEpoch (getField @ " _d" (toLedgerPParams sbe pParams)))
@@ -1515,10 +1517,10 @@ currentEpochEligibleLeadershipSlots :: forall era ledgerera. ()
1515
1517
-> ProtocolState era
1516
1518
-> PoolId
1517
1519
-> SigningKey VrfKey
1518
- -> SerialisedCurrentEpochState era
1520
+ -> SerialisedPoolDistribution era
1519
1521
-> EpochNo -- ^ Current EpochInfo
1520
1522
-> Either LeadershipError (Set SlotNo )
1521
- currentEpochEligibleLeadershipSlots sbe sGen eInfo pParams ptclState poolid (VrfSigningKey vrkSkey) serCurrEpochState currentEpoch = do
1523
+ currentEpochEligibleLeadershipSlots sbe sGen eInfo pParams ptclState poolid (VrfSigningKey vrkSkey) serPoolDistr currentEpoch = do
1522
1524
1523
1525
chainDepState :: ChainDepState (Api. ConsensusProtocol era ) <-
1524
1526
first LeaderErrDecodeProtocolStateFailure $ decodeProtocolState ptclState
@@ -1531,17 +1533,10 @@ currentEpochEligibleLeadershipSlots sbe sGen eInfo pParams ptclState poolid (Vrf
1531
1533
(firstSlotOfEpoch, lastSlotofEpoch) :: (SlotNo , SlotNo ) <- first LeaderErrSlotRangeCalculationFailure
1532
1534
$ Slot. epochInfoRange eInfo currentEpoch
1533
1535
1534
- CurrentEpochState (cEstate :: ShelleyAPI. EpochState ( ShelleyLedgerEra era )) <-
1535
- first LeaderErrDecodeProtocolEpochStateFailure
1536
+ setSnapshotPoolDistr <-
1537
+ first LeaderErrDecodeProtocolEpochStateFailure . fmap ( SL. unPoolDistr . unPoolDistr)
1536
1538
$ obtainDecodeEpochStateConstraints sbe
1537
- $ decodeCurrentEpochState serCurrEpochState
1538
-
1539
- -- We need the "set" stake distribution (distribution of the previous epoch)
1540
- -- in order to calculate the leadership schedule of the current epoch.
1541
- let setSnapshotPoolDistr :: Map (SL. KeyHash 'SL.StakePool Shelley. StandardCrypto ) (SL. IndividualPoolStake Shelley. StandardCrypto )
1542
- setSnapshotPoolDistr = ShelleyAPI. unPoolDistr . ShelleyAPI. calculatePoolDistr
1543
- . ShelleyAPI. _pstakeSet . obtainIsStandardCrypto sbe
1544
- $ ShelleyAPI. esSnapshots cEstate
1539
+ $ decodePoolDistribution serPoolDistr
1545
1540
1546
1541
let slotRangeOfInterest = Set. filter
1547
1542
(not . Ledger. isOverlaySlot firstSlotOfEpoch (getField @ " _d" (toLedgerPParams sbe pParams)))
0 commit comments