@@ -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 (.. ), PoolDistr (unPoolDistr ), ProtocolState ,
109
+ SerialisedCurrentEpochState (.. ), SerialisedPoolDistr , decodeCurrentEpochState ,
110
+ decodePoolDistr , decodeProtocolState )
110
111
import Cardano.Binary (DecoderError , FromCBOR )
111
112
import qualified Cardano.Chain.Genesis
112
113
import qualified Cardano.Chain.Update
@@ -1384,9 +1385,10 @@ nextEpochEligibleLeadershipSlots sbe sGen serCurrEpochState ptclState poolid (Vr
1384
1385
$ obtainDecodeEpochStateConstraints sbe
1385
1386
$ decodeCurrentEpochState serCurrEpochState
1386
1387
1387
- let markSnapshotPoolDistr :: Map (SL. KeyHash 'SL.StakePool Shelley. StandardCrypto ) (SL. IndividualPoolStake Shelley. StandardCrypto )
1388
- markSnapshotPoolDistr = ShelleyAPI. unPoolDistr . ShelleyAPI. calculatePoolDistr . ShelleyAPI. _pstakeMark
1389
- $ obtainIsStandardCrypto sbe $ ShelleyAPI. esSnapshots cEstate
1388
+ let snapshot :: ShelleyAPI. SnapShot Shelley. StandardCrypto
1389
+ snapshot = ShelleyAPI. _pstakeMark $ obtainIsStandardCrypto sbe $ ShelleyAPI. esSnapshots cEstate
1390
+ markSnapshotPoolDistr :: Map (SL. KeyHash 'SL.StakePool Shelley. StandardCrypto ) (SL. IndividualPoolStake Shelley. StandardCrypto )
1391
+ markSnapshotPoolDistr = ShelleyAPI. unPoolDistr . ShelleyAPI. calculatePoolDistr $ snapshot
1390
1392
1391
1393
let slotRangeOfInterest = Set. filter
1392
1394
(not . Ledger. isOverlaySlot firstSlotOfEpoch (getField @ " _d" (toLedgerPParams sbe pParams)))
@@ -1510,10 +1512,10 @@ currentEpochEligibleLeadershipSlots :: forall era ledgerera. ()
1510
1512
-> ProtocolState era
1511
1513
-> PoolId
1512
1514
-> SigningKey VrfKey
1513
- -> SerialisedCurrentEpochState era
1515
+ -> SerialisedPoolDistr era
1514
1516
-> EpochNo -- ^ Current EpochInfo
1515
1517
-> Either LeadershipError (Set SlotNo )
1516
- currentEpochEligibleLeadershipSlots sbe sGen eInfo pParams ptclState poolid (VrfSigningKey vrkSkey) serCurrEpochState currentEpoch = do
1518
+ currentEpochEligibleLeadershipSlots sbe sGen eInfo pParams ptclState poolid (VrfSigningKey vrkSkey) serPoolDistr currentEpoch = do
1517
1519
1518
1520
chainDepState :: ChainDepState (Api. ConsensusProtocol era ) <-
1519
1521
first LeaderErrDecodeProtocolStateFailure $ decodeProtocolState ptclState
@@ -1526,17 +1528,10 @@ currentEpochEligibleLeadershipSlots sbe sGen eInfo pParams ptclState poolid (Vrf
1526
1528
(firstSlotOfEpoch, lastSlotofEpoch) :: (SlotNo , SlotNo ) <- first LeaderErrSlotRangeCalculationFailure
1527
1529
$ Slot. epochInfoRange eInfo currentEpoch
1528
1530
1529
- CurrentEpochState (cEstate :: ShelleyAPI. EpochState ( ShelleyLedgerEra era )) <-
1530
- first LeaderErrDecodeProtocolEpochStateFailure
1531
+ setSnapshotPoolDistr <-
1532
+ first LeaderErrDecodeProtocolEpochStateFailure . fmap ( SL. unPoolDistr . unPoolDistr)
1531
1533
$ obtainDecodeEpochStateConstraints sbe
1532
- $ decodeCurrentEpochState serCurrEpochState
1533
-
1534
- -- We need the "set" stake distribution (distribution of the previous epoch)
1535
- -- in order to calculate the leadership schedule of the current epoch.
1536
- let setSnapshotPoolDistr :: Map (SL. KeyHash 'SL.StakePool Shelley. StandardCrypto ) (SL. IndividualPoolStake Shelley. StandardCrypto )
1537
- setSnapshotPoolDistr = ShelleyAPI. unPoolDistr . ShelleyAPI. calculatePoolDistr
1538
- . ShelleyAPI. _pstakeSet . obtainIsStandardCrypto sbe
1539
- $ ShelleyAPI. esSnapshots cEstate
1534
+ $ decodePoolDistr serPoolDistr
1540
1535
1541
1536
let slotRangeOfInterest = Set. filter
1542
1537
(not . Ledger. isOverlaySlot firstSlotOfEpoch (getField @ " _d" (toLedgerPParams sbe pParams)))
0 commit comments