-
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
Simplify by not using QueryStakeAddressInfoCmdArgs
unnecessarily
#1184
Conversation
{ Cmd.commons = commons | ||
, addr | ||
, outputFormat | ||
, mOutFile -- unused anyway. TODO tighten this by removing the field. |
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
and mOutFile
are unused by callQueryStakeAddressInfoCmd
, so don't bother using QueryStakeAddressInfoCmdArgs
and packing unnecessary fields.
spoToDelegatee <- | ||
Map.fromList . concat | ||
<$> traverse | ||
( \stakeAddr -> do | ||
info <- callQueryStakeAddressInfoCmd $ mkQueryStakeAddressInfoCmdArgs stakeAddr | ||
info <- callQueryStakeAddressInfoCmd commons stakeAddr |
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.
Instead call callQueryStakeAddressInfoCmd
with the values it needs directly.
@@ -1801,7 +1799,6 @@ runQuerySPOStakeDistribution | |||
, Cmd.target | |||
} | |||
, Cmd.spoHashSources = spoHashSources' | |||
, Cmd.outputFormat |
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.
The unnecessary use of QueryStakeAddressInfoCmdArgs
hides problems. For example here outputFormat
is actually unused, when it really should be. The use of QueryStakeAddressInfoCmdArgs
hides this fact.
…se it is not a command function
[ ( 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 comment
The reason will be displayed to describe this comment to others. Learn more.
We now respect the output format of the query spo-stake-distribution
command.
writeOutput mOutFile toWrite | ||
output = | ||
outputFormat | ||
& ( id |
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.
Is this id
to get alignment from the formatter? I don't think it has any effect on the code
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.
Yes, it is purely for alignment purposes.
Changelog
Context
Don't build a value of a data type if it doesn't make sense to use all the fields. Just pass the values directly to the function instead.
How to trust this PR
Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.
Checklist