Skip to content

Commit

Permalink
Merge pull request #541 from IntersectMBO/ch/clarify-all-or-some-flags
Browse files Browse the repository at this point in the history
Clarify stake-pool queries with an "all or some"-logic
  • Loading branch information
carlhammann committed Jan 9, 2024
2 parents 5e8ee57 + 4823900 commit 6386a51
Show file tree
Hide file tree
Showing 56 changed files with 227 additions and 342 deletions.
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

0 comments on commit 6386a51

Please sign in to comment.