Skip to content

Conversation

@random-zebra
Copy link

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).

@random-zebra random-zebra added Cleanup Trivial extremely simple issues labels Jan 15, 2020
@random-zebra random-zebra self-assigned this Jan 15, 2020
@Fuzzbawls Fuzzbawls added this to the 4.1.0 milestone Jan 18, 2020
@Fuzzbawls
Copy link
Collaborator

needs rebase

@random-zebra random-zebra force-pushed the 2020_GetBlocksToMaturity branch from 18f331c to 97405bd Compare January 21, 2020 10:05
@random-zebra
Copy link
Author

Rebased. Only one instance is left (the other one was fixed in bc6ae73).

@random-zebra random-zebra force-pushed the 2020_GetBlocksToMaturity branch from 97405bd to 4d38d42 Compare January 21, 2020 17:59
Copy link

@furszy furszy left a 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()) {
Copy link

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.

  1. GetBlocksToMaturity is calling internally GetDepthInMainChain.
  2. IsInMainChain is calling internally GetDepthInMainChain.

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 4d38d42

random-zebra added a commit that referenced this pull request Jan 23, 2020
…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
@random-zebra random-zebra merged commit 4d38d42 into PIVX-Project:master Jan 23, 2020
furszy added a commit that referenced this pull request Feb 4, 2020
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
wqking pushed a commit to wqking-temp/Vitae that referenced this pull request Jul 29, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cleanup Trivial extremely simple issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants