Skip to content

Commit

Permalink
cardano-cli query kes-period-info: Always display metrics (#3627)
Browse files Browse the repository at this point in the history
  • Loading branch information
cblp authored and Jimbo4350 committed Mar 31, 2022
1 parent 78675fb commit a1d2067
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -429,33 +429,25 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
(opCertCounter, ptclStateCounter, opCertCounterStateDiag) <- opCertCounterStateCheck ptclState opCert

let diagnoses = opCertCounterStateDiag ++ [periodCheckDiag]

if any anyFailureDiagnostic diagnoses
then
case mOutFile of
Just (OutputFile _) -> liftIO $ mapM_ kesOpCertDiagnosticsRender diagnoses
Nothing -> liftIO $ mapM_ kesOpCertDiagnosticsRender diagnoses
else do
let kesPeriodInfo = O.QueryKesPeriodInfoOutput
{ O.qKesInfoCurrentKESPeriod = currentKesPeriod
, O.qKesInfoStartKesInterval = kesIntervalStart
, O.qKesInfoStartEndInterval = kesIntervalEnd
, O.qKesInfoRemainingSlotsInPeriod = slotsTillNewKesKey
, O.qKesInfoNodeStateOperationalCertNo = ptclStateCounter
, O.qKesInfoOnDiskOperationalCertNo = opCertCounter
, O.qKesInfoMaxKesKeyEvolutions = fromIntegral protocolParamMaxKESEvolutions
, O.qKesInfoSlotsPerKesPeriod = fromIntegral protocolParamSlotsPerKESPeriod
, O.qKesInfoKesKeyExpiry = kesKeyExpirySlotUtc
}
kesPeriodInfoJSON = encodePretty kesPeriodInfo

liftIO $ mapM_ kesOpCertDiagnosticsRender diagnoses

case mOutFile of
Just (OutputFile oFp) ->
handleIOExceptT (ShelleyQueryCmdWriteFileError . FileIOError oFp)
$ LBS.writeFile oFp kesPeriodInfoJSON
Nothing -> liftIO $ LBS.putStrLn kesPeriodInfoJSON
liftIO $ mapM_ kesOpCertDiagnosticsRender diagnoses

let kesPeriodInfo = O.QueryKesPeriodInfoOutput
{ O.qKesInfoCurrentKESPeriod = currentKesPeriod
, O.qKesInfoStartKesInterval = kesIntervalStart
, O.qKesInfoStartEndInterval = kesIntervalEnd
, O.qKesInfoRemainingSlotsInPeriod = slotsTillNewKesKey
, O.qKesInfoNodeStateOperationalCertNo = ptclStateCounter
, O.qKesInfoOnDiskOperationalCertNo = opCertCounter
, O.qKesInfoMaxKesKeyEvolutions = fromIntegral protocolParamMaxKESEvolutions
, O.qKesInfoSlotsPerKesPeriod = fromIntegral protocolParamSlotsPerKESPeriod
, O.qKesInfoKesKeyExpiry = kesKeyExpirySlotUtc
}
kesPeriodInfoJSON = encodePretty kesPeriodInfo
case mOutFile of
Just (OutputFile oFp) ->
handleIOExceptT (ShelleyQueryCmdWriteFileError . FileIOError oFp)
$ LBS.writeFile oFp kesPeriodInfoJSON
Nothing -> liftIO $ LBS.putStrLn kesPeriodInfoJSON

mode -> left . ShelleyQueryCmdUnsupportedMode $ AnyConsensusMode mode
where
Expand Down Expand Up @@ -621,10 +613,6 @@ data KesOpCertDiagnostic = SuccessDiagnostic SuccessDiagnostic
| FailureDiagnostic FailureDiagnostic


anyFailureDiagnostic :: KesOpCertDiagnostic -> Bool
anyFailureDiagnostic FailureDiagnostic{} = True
anyFailureDiagnostic SuccessDiagnostic{} = False

data SuccessDiagnostic
= OpCertCounterMoreThanOrEqualToNodeState
| OpCertCounterMoreThanOrEqualToZero
Expand Down

0 comments on commit a1d2067

Please sign in to comment.