-
Notifications
You must be signed in to change notification settings - Fork 725
[Trivial][Cleanup] Remove extra checks before GetBlocksToMaturity #1281
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
[Trivial][Cleanup] Remove extra checks before GetBlocksToMaturity #1281
Conversation
|
needs rebase |
18f331c to
97405bd
Compare
|
Rebased. Only one instance is left (the other one was fixed in bc6ae73). |
97405bd to
4d38d42
Compare
furszy
left a comment
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 left you a comment but it's more an overall improvement to the whole wallet class methods and not related to this PR only.
This is ok, ACK 4d38d42
| { | ||
| LOCK(cs_main); | ||
| if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0 && IsInMainChain()) { | ||
| if (GetBlocksToMaturity() > 0 && IsInMainChain()) { |
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 can unified in just a single method call.
GetBlocksToMaturityis calling internallyGetDepthInMainChain.IsInMainChainis calling internallyGetDepthInMainChain.
Fuzzbawls
left a comment
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.
utACK 4d38d42
…oMaturity 4d38d42 [Wallet] Remove extra checks before GetBlocksToMaturity (random-zebra) Pull request description: Ref: #1263 (comment) `GetBlocksToMaturity` returns `0` for txes that are neither coinbases nor coinstakes, so no need to check that before. There are actually only two places needing this quick cleanup. Note: there are, instead, several occurrences of `if (IsCoinBase() && GetBlocksToMaturity() > 0)` (i.e. test failing for coinstakes but not coinbases). These need further inspection because a change there affects reported balances (e.g. in `CWalletTx::UpdateAmount` or `CWalletTx::GetUnlockedCredit`). ACKs for top commit: furszy: This is ok, ACK 4d38d42 Fuzzbawls: utACK 4d38d42 Tree-SHA512: 50693af631a653be940a77aa6a52ec17490236fd56a843536689a0e04c0a10c85edeccd254aa389d84d89c24fb916d54c3703bf8eb18d958d9ee1bbd0428ea60
b32e418 [Wallet] Add function CMerkleTx::IsInMainChainImmature (random-zebra) Pull request description: This introduces a little performance optimization, removing the double call to `GetDepthInMainChain` (ref: #1281 (comment)). Note: in a successive PR we should review the LOCKs in this area of the wallet. ACKs for top commit: furszy: utACK b32e418 Tree-SHA512: 69e16557dd67e0450b3b9a14a3a182be39bdfcec8ef5a49ca156d9511cd9a7a532c650ed8440b147795dc3d003d10f1c8c737d0990db6365cdada2eb66997892
b32e4181f3b644ebe7d432b3308fee18ee8d7e6f [Wallet] Add function CMerkleTx::IsInMainChainImmature (random-zebra) Pull request description: This introduces a little performance optimization, removing the double call to `GetDepthInMainChain` (ref: PIVX-Project/PIVX#1281 (comment)). Note: in a successive PR we should review the LOCKs in this area of the wallet. ACKs for top commit: furszy: utACK b32e418 Tree-SHA512: 69e16557dd67e0450b3b9a14a3a182be39bdfcec8ef5a49ca156d9511cd9a7a532c650ed8440b147795dc3d003d10f1c8c737d0990db6365cdada2eb66997892
Ref: #1263 (comment)
GetBlocksToMaturityreturns0for txes that are neither coinbases nor coinstakes, so no need to check that before.There are actually only two places needing this quick cleanup.
Note: there are, instead, several occurrences of
if (IsCoinBase() && GetBlocksToMaturity() > 0)(i.e. test failing for coinstakes but not coinbases).These need further inspection because a change there affects reported balances (e.g. in
CWalletTx::UpdateAmountorCWalletTx::GetUnlockedCredit).