Skip to content

Commit

Permalink
Merge pull request #635 from IntersectMBO/neilmayhew/pool-state-outpu…
Browse files Browse the repository at this point in the history
…t-file

Allow an output file to be specified for query pool-state
  • Loading branch information
smelc authored Mar 6, 2024
2 parents 156820e + ba4fb94 commit b0ede7b
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 4 deletions.
1 change: 1 addition & 0 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs
, networkId :: !NetworkId
, allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey))
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ pQueryPoolStateCmd era envCli =
<*> pNetworkId envCli
<*> pAllStakePoolsOrSome
<*> pTarget era
<*> pMaybeOutputFile

pQueryTxMempoolCmd :: EnvCli -> Parser (QueryCmds era)
pQueryTxMempoolCmd envCli =
Expand Down
11 changes: 7 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ runQueryPoolStateCmd
, Cmd.networkId
, Cmd.allOrOnlyPoolIds
, Cmd.target
, Cmd.mOutFile
} = do
let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath

Expand All @@ -635,7 +636,7 @@ runQueryPoolStateCmd
& onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError)

pure $ do
shelleyBasedEraConstraints sbe writePoolState result
shelleyBasedEraConstraints sbe (writePoolState mOutFile) result
)
& onLeft (left . QueryCmdAcquireFailure)
& onLeft left
Expand Down Expand Up @@ -939,9 +940,10 @@ writePoolState :: forall era ledgerera. ()
=> ShelleyLedgerEra era ~ ledgerera
=> L.EraCrypto ledgerera ~ StandardCrypto
=> L.Era ledgerera
=> SerialisedPoolState era
=> Maybe (File () Out)
-> SerialisedPoolState era
-> ExceptT QueryCmdError IO ()
writePoolState serialisedCurrentEpochState = do
writePoolState mOutFile serialisedCurrentEpochState = do
PoolState poolState <- pure (decodePoolState serialisedCurrentEpochState)
& onLeft (left . QueryCmdPoolStateDecodeError)

Expand All @@ -960,7 +962,8 @@ writePoolState serialisedCurrentEpochState = do
)
)

liftIO . LBS.putStrLn $ encodePretty poolStates
firstExceptT QueryCmdWriteFileError . newExceptT $
writeLazyByteStringOutput mOutFile $ encodePretty poolStates

writeProtocolState
:: ShelleyBasedEra era
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ data LegacyQueryPoolStateCmdArgs = LegacyQueryPoolStateCmdArgs
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey))
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data LegacyQueryTxMempoolCmdArgs = LegacyQueryTxMempoolCmdArgs
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ pQueryCmds envCli =
<*> pConsensusModeParams
<*> pNetworkId envCli
<*> pAllStakePoolsOrOnly
<*> pMaybeOutputFile

pQueryTxMempool :: Parser LegacyQueryCmds
pQueryTxMempool =
Expand Down
18 changes: 18 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ Usage: cardano-cli shelley query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -602,6 +603,7 @@ Usage: cardano-cli shelley query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand Down Expand Up @@ -1722,6 +1724,7 @@ Usage: cardano-cli allegra query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -1765,6 +1768,7 @@ Usage: cardano-cli allegra query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand Down Expand Up @@ -2883,6 +2887,7 @@ Usage: cardano-cli mary query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -2924,6 +2929,7 @@ Usage: cardano-cli mary query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand Down Expand Up @@ -4036,6 +4042,7 @@ Usage: cardano-cli alonzo query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -4079,6 +4086,7 @@ Usage: cardano-cli alonzo query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand Down Expand Up @@ -5224,6 +5232,7 @@ Usage: cardano-cli babbage query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -5267,6 +5276,7 @@ Usage: cardano-cli babbage query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand Down Expand Up @@ -6679,6 +6689,7 @@ Usage: cardano-cli conway query pool-params --socket-path SOCKET_PATH
| (--stake-pool-id STAKE_POOL_ID)
)
[--volatile-tip | --immutable-tip]
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -6729,6 +6740,7 @@ Usage: cardano-cli conway query pool-state --socket-path SOCKET_PATH
| (--stake-pool-id STAKE_POOL_ID)
)
[--volatile-tip | --immutable-tip]
[--out-file FILE]

Dump the pool state

Expand Down Expand Up @@ -8034,6 +8046,7 @@ Usage: cardano-cli latest query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -8077,6 +8090,7 @@ Usage: cardano-cli latest query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand Down Expand Up @@ -9051,6 +9065,7 @@ Usage: cardano-cli legacy query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -9094,6 +9109,7 @@ Usage: cardano-cli legacy query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand Down Expand Up @@ -10292,6 +10308,7 @@ Usage: cardano-cli query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -10330,6 +10347,7 @@ Usage: cardano-cli query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli allegra query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -30,4 +31,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli allegra query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand All @@ -28,4 +29,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli alonzo query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -30,4 +31,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli alonzo query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand All @@ -28,4 +29,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli babbage query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -30,4 +31,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli babbage query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand All @@ -28,4 +29,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Usage: cardano-cli conway query pool-params --socket-path SOCKET_PATH
| (--stake-pool-id STAKE_POOL_ID)
)
[--volatile-tip | --immutable-tip]
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -34,4 +35,5 @@ Available options:
--volatile-tip Use the volatile tip as a target. (This is the
default)
--immutable-tip Use the immutable tip as a target.
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Usage: cardano-cli conway query pool-state --socket-path SOCKET_PATH
| (--stake-pool-id STAKE_POOL_ID)
)
[--volatile-tip | --immutable-tip]
[--out-file FILE]

Dump the pool state

Expand All @@ -32,4 +33,5 @@ Available options:
--volatile-tip Use the volatile tip as a target. (This is the
default)
--immutable-tip Use the immutable tip as a target.
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli latest query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -30,4 +31,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli latest query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand All @@ -28,4 +29,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli legacy query pool-params --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -30,4 +31,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Usage: cardano-cli legacy query pool-state --socket-path SOCKET_PATH
( --all-stake-pools
| (--stake-pool-id STAKE_POOL_ID)
)
[--out-file FILE]

Dump the pool state

Expand All @@ -28,4 +29,5 @@ Available options:
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded).
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Loading

0 comments on commit b0ede7b

Please sign in to comment.