-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix addGenesisAccount #4281
Fix addGenesisAccount #4281
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4281 +/- ##
==========================================
+ Coverage 59.1% 59.13% +0.02%
==========================================
Files 217 217
Lines 14595 14603 +8
==========================================
+ Hits 8627 8635 +8
Misses 5330 5330
Partials 638 638 |
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.
ACKed. Thanks!
4adf7eb
to
2022fe6
Compare
func (coins Coins) IsAnyGT(coinsB Coins) bool { | ||
if len(coinsB) == 0 { | ||
return false | ||
} |
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.
This should be
// if len(coins) = 0 we know for sure no amount in coins can be GT coinsB
if len(coins) == 0 {
return false
}
// we learned from the above that coins contains some coins,
// thus if len(coinsB) == 0 we know for sure there's something GT
if len(coinsB) == 0 {
return true
}
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.
Again, it is important to be consistent across the methods. This behaves the same as IsAnyGTE
. If coinsB
then no denom is present and thus no coin is GT.
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.
This:
if len(coins) == 0 {
return false
}
adds a bit of extra readability (thanks to early return) and does not conflict with If coinsB then no denom is present and thus no coin is GT.
, in fact the for _, coin := range coins
would just not be executed anyway when len(coins) == 0
. Also it does not break consistency with IsAnyGTE
.
Though I see your point, this should be dropped:
if len(coinsB) == 0 {
return true
}
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.
Ok, I'll update.
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.
Actually,
if len(coins) == 0 {
return false
}
is redundant though.
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.
I said so above :)
in fact the for _, coin := range coins would just not be executed anyway when len(coins) == 0
It's just early return, readability is added by sparing the reader from continuing reading the rest of the function when len(coins) == 0
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.
tbh I don't think this is necessary at all. The method is pretty concise as-is.
Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com>
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.
nice
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.
LGTM
closes: #4271
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added a relevant changelog entry:
clog add [section] [stanza] [message]
rereviewed
Files changed
in the github PR explorerFor Admin Use: