-
Notifications
You must be signed in to change notification settings - Fork 19
Simplify by not using QueryStakeAddressInfoCmdArgs
unnecessarily
#1184
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -962,12 +962,13 @@ runQueryStakeAddressInfoCmd | |
=> Cmd.QueryStakeAddressInfoCmdArgs | ||
-> ExceptT QueryCmdError IO () | ||
runQueryStakeAddressInfoCmd | ||
cmd@Cmd.QueryStakeAddressInfoCmdArgs | ||
Cmd.QueryStakeAddressInfoCmdArgs | ||
{ Cmd.commons = | ||
Cmd.QueryCommons | ||
commons@Cmd.QueryCommons | ||
{ Cmd.nodeConnInfo | ||
, Cmd.target | ||
} | ||
, Cmd.addr | ||
, Cmd.outputFormat | ||
, Cmd.mOutFile | ||
} = do | ||
|
@@ -978,11 +979,11 @@ runQueryStakeAddressInfoCmd | |
& onLeft (left . QueryCmdUnsupportedNtcVersion) | ||
sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) | ||
|
||
said <- callQueryStakeAddressInfoCmd cmd | ||
said <- getQueryStakeAddressInfo commons addr | ||
|
||
writeStakeAddressInfo sbe said outputFormat mOutFile | ||
|
||
-- | Container for data returned by 'callQueryStakeAddressInfoCmd' where: | ||
-- | Container for data returned by 'getQueryStakeAddressInfo' where: | ||
data StakeAddressInfoData = StakeAddressInfoData | ||
{ rewards :: DelegationsAndRewards | ||
-- ^ Rewards: map of stake addresses to pool ID and rewards balance. | ||
|
@@ -995,19 +996,16 @@ data StakeAddressInfoData = StakeAddressInfoData | |
-- ^ Delegatees: map of stake addresses and their vote delegation preference. | ||
} | ||
|
||
callQueryStakeAddressInfoCmd | ||
:: () | ||
=> Cmd.QueryStakeAddressInfoCmdArgs | ||
getQueryStakeAddressInfo | ||
:: Cmd.QueryCommons | ||
-> StakeAddress | ||
-> ExceptT QueryCmdError IO StakeAddressInfoData | ||
callQueryStakeAddressInfoCmd | ||
Cmd.QueryStakeAddressInfoCmdArgs | ||
{ Cmd.commons = | ||
Cmd.QueryCommons | ||
{ Cmd.nodeConnInfo = nodeConnInfo@LocalNodeConnectInfo{localNodeNetworkId = networkId} | ||
, Cmd.target | ||
} | ||
, Cmd.addr = StakeAddress _ addr | ||
} = | ||
getQueryStakeAddressInfo | ||
Cmd.QueryCommons | ||
{ Cmd.nodeConnInfo = nodeConnInfo@LocalNodeConnectInfo{localNodeNetworkId = networkId} | ||
, Cmd.target | ||
} | ||
(StakeAddress _ addr) = | ||
do | ||
lift $ executeLocalStateQueryExpr nodeConnInfo target $ runExceptT $ do | ||
AnyCardanoEra era <- easyRunQueryCurrentEra | ||
|
@@ -1835,19 +1833,11 @@ runQuerySPOStakeDistribution | |
| (keyHash, addr) <- Map.toList $ L.psStakePoolParams poolState | ||
] | ||
|
||
mkQueryStakeAddressInfoCmdArgs addr = | ||
Cmd.QueryStakeAddressInfoCmdArgs | ||
{ Cmd.commons = commons | ||
, addr | ||
, outputFormat | ||
, mOutFile -- unused anyway. TODO tighten this by removing the field. | ||
} | ||
|
||
spoToDelegatee <- | ||
Map.fromList . concat | ||
<$> traverse | ||
( \stakeAddr -> do | ||
info <- callQueryStakeAddressInfoCmd $ mkQueryStakeAddressInfoCmdArgs stakeAddr | ||
info <- getQueryStakeAddressInfo commons stakeAddr | ||
return $ | ||
[ (spo, delegatee) | ||
| (Just spo, delegatee) <- | ||
|
@@ -1856,15 +1846,26 @@ runQuerySPOStakeDistribution | |
) | ||
(Map.keys addressesAndRewards) | ||
|
||
let toWrite = | ||
let json = | ||
[ ( spo | ||
, coin | ||
, Map.lookup spo spoToDelegatee | ||
) | ||
| (spo, coin) <- Map.assocs spoStakeDistribution | ||
] | ||
|
||
writeOutput mOutFile toWrite | ||
output = | ||
outputFormat | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now respect the output format of the |
||
& ( id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is purely for alignment purposes. |
||
. Vary.on (\FormatJson -> Json.encodeJson) | ||
. Vary.on (\FormatYaml -> Json.encodeYaml) | ||
$ Vary.exhaustiveCase | ||
) | ||
$ json | ||
|
||
firstExceptT QueryCmdWriteFileError | ||
. newExceptT | ||
$ writeLazyByteStringOutput mOutFile output | ||
|
||
runQueryCommitteeMembersState | ||
:: Cmd.QueryCommitteeMembersStateCmdArgs era | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
outputFormat
andmOutFile
are unused bycallQueryStakeAddressInfoCmd
, so don't bother usingQueryStakeAddressInfoCmdArgs
and packing unnecessary fields.