Skip to content

Commit

Permalink
Query over single connection in runQueryLeadershipSchedule
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jul 30, 2023
1 parent f704350 commit 7c0fa56
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cardano-cli/src/Cardano/CLI/Run/Legacy/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,15 +1392,15 @@ runQueryLeadershipSchedule
bpp <- hoistEither . first ShelleyQueryCmdProtocolParameterConversionError $
bundleProtocolParams era pparams

pure $ do
schedule <- case whichSchedule of
CurrentEpoch -> do
case whichSchedule of
CurrentEpoch -> do
pure $ do
serCurrentEpochState <- lift (executeLocalStateQueryExpr localNodeConnInfo Nothing $ queryPoolDistribution eInMode sbe (Just (Set.singleton poolid)))
& onLeft (left . ShelleyQueryCmdAcquireFailure)
& onLeft (left . ShelleyQueryCmdUnsupportedNtcVersion)
& onLeft (left . ShelleyQueryCmdLocalStateQueryError . EraMismatchError)

firstExceptT ShelleyQueryCmdLeaderShipError $ hoistEither
schedule <- firstExceptT ShelleyQueryCmdLeaderShipError $ hoistEither
$ shelleyBasedEraConstraints sbe
$ currentEpochEligibleLeadershipSlots
sbe
Expand All @@ -1413,20 +1413,24 @@ runQueryLeadershipSchedule
serCurrentEpochState
curentEpoch

NextEpoch -> do
writeSchedule mJsonOutputFile eInfo shelleyGenesis schedule

NextEpoch -> do
pure $ do
serCurrentEpochState <- lift (executeLocalStateQueryExpr localNodeConnInfo Nothing $ queryCurrentEpochState eInMode sbe)
& onLeft (left . ShelleyQueryCmdAcquireFailure)
& onLeft (left . ShelleyQueryCmdUnsupportedNtcVersion)
& onLeft (left . ShelleyQueryCmdLocalStateQueryError . EraMismatchError)

tip <- liftIO $ getLocalChainTip localNodeConnInfo

firstExceptT ShelleyQueryCmdLeaderShipError $ hoistEither
schedule <- firstExceptT ShelleyQueryCmdLeaderShipError $ hoistEither
$ shelleyBasedEraConstraints sbe
$ nextEpochEligibleLeadershipSlots sbe shelleyGenesis
serCurrentEpochState ptclState poolid vrkSkey bpp
eInfo (tip, curentEpoch)
writeSchedule mJsonOutputFile eInfo shelleyGenesis schedule

writeSchedule mJsonOutputFile eInfo shelleyGenesis schedule
mode ->
pure $ do
left . ShelleyQueryCmdUnsupportedMode $ AnyConsensusMode mode
Expand Down

0 comments on commit 7c0fa56

Please sign in to comment.