Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify stake-pool queries with an "all or some"-logic #541

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ data QueryStakeSnapshotCmdArgs = QueryStakeSnapshotCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey])
, allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey))
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

Expand All @@ -155,7 +155,7 @@ data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey])
, allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey))
} deriving (Generic, Show)

data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs
Expand Down
6 changes: 2 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2294,10 +2294,8 @@ pStakePoolVerificationKeyHash prefix =
Opt.option (pBech32KeyHash AsStakePoolKey <|> pHexHash AsStakePoolKey) $ mconcat
[ Opt.long $ prefixFlag prefix "stake-pool-id"
, Opt.metavar "STAKE_POOL_ID"
, Opt.help $ mconcat
[ "Stake pool ID/verification key hash (either Bech32-encoded or hex-encoded). "
, "Zero or more occurences of this option is allowed."
]
, Opt.help
"Stake pool ID/verification key hash (either Bech32-encoded or hex-encoded)."
]

pVrfVerificationKeyFile :: Parser (VerificationKeyFile In)
Expand Down
14 changes: 7 additions & 7 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ pQueryProtocolStateCmd envCli =
<*> pNetworkId envCli
<*> pMaybeOutputFile

pAllStakePoolsOrOnly :: Parser (AllOrOnly [Hash StakePoolKey])
pAllStakePoolsOrOnly = pAll <|> pOnly
where pAll :: Parser (AllOrOnly [Hash StakePoolKey])
pAllStakePoolsOrSome :: Parser (AllOrOnly (Hash StakePoolKey))
pAllStakePoolsOrSome = pAll <|> pOnly
where pAll :: Parser (AllOrOnly (Hash StakePoolKey))
pAll = Opt.flag' All $ mconcat
[ Opt.long "all-stake-pools"
, Opt.help "Query for all stake pools"
]
pOnly :: Parser (AllOrOnly [Hash StakePoolKey])
pOnly = Only <$> many (pStakePoolVerificationKeyHash Nothing)
pOnly :: Parser (AllOrOnly (Hash StakePoolKey))
pOnly = Only <$> some (pStakePoolVerificationKeyHash Nothing)

pQueryStakeSnapshotCmd :: EnvCli -> Parser (QueryCmds era)
pQueryStakeSnapshotCmd envCli =
Expand All @@ -206,7 +206,7 @@ pQueryStakeSnapshotCmd envCli =
<$> pSocketPath envCli
<*> pConsensusModeParams
<*> pNetworkId envCli
<*> pAllStakePoolsOrOnly
<*> pAllStakePoolsOrSome
<*> pMaybeOutputFile

pQueryPoolStateCmd :: EnvCli -> Parser (QueryCmds era)
Expand All @@ -216,7 +216,7 @@ pQueryPoolStateCmd envCli =
<$> pSocketPath envCli
<*> pConsensusModeParams
<*> pNetworkId envCli
<*> pAllStakePoolsOrOnly
<*> pAllStakePoolsOrSome

pQueryTxMempoolCmd :: EnvCli -> Parser (QueryCmds era)
pQueryTxMempoolCmd envCli =
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ data LegacyQueryStakeSnapshotCmdArgs = LegacyQueryStakeSnapshotCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey])
, allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey))
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

Expand All @@ -145,7 +145,7 @@ data LegacyQueryPoolStateCmdArgs = LegacyQueryPoolStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey])
, allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey))
} deriving (Generic, Show)

data LegacyQueryTxMempoolCmdArgs = LegacyQueryTxMempoolCmdArgs
Expand Down
8 changes: 4 additions & 4 deletions cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,15 @@ pQueryCmds envCli =
<*> pNetworkId envCli
<*> pMaybeOutputFile

pAllStakePoolsOrOnly :: Parser (AllOrOnly [Hash StakePoolKey])
pAllStakePoolsOrOnly :: Parser (AllOrOnly (Hash StakePoolKey))
pAllStakePoolsOrOnly = pAll <|> pOnly
where pAll :: Parser (AllOrOnly [Hash StakePoolKey])
where pAll :: Parser (AllOrOnly (Hash StakePoolKey))
pAll = Opt.flag' All $ mconcat
[ Opt.long "all-stake-pools"
, Opt.help "Query for all stake pools"
]
pOnly :: Parser (AllOrOnly [Hash StakePoolKey])
pOnly = Only <$> many (pStakePoolVerificationKeyHash Nothing)
pOnly :: Parser (AllOrOnly (Hash StakePoolKey))
pOnly = Only <$> some (pStakePoolVerificationKeyHash Nothing)

pQueryStakeSnapshot :: Parser LegacyQueryCmds
pQueryStakeSnapshot =
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Types/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ data KeyOutputFormat
| KeyOutputFormatBech32
deriving (Eq, Show)

data AllOrOnly a = All | Only a deriving (Eq, Show)
data AllOrOnly a = All | Only [a] deriving (Eq, Show)

-- | This data structure is used to allow nicely formatted output in the query pool-params command.
-- params are the current pool parameter settings, futureparams are new parameters, retiringEpoch is the
Expand Down
Loading