Skip to content
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 rescanblockchain rpc to properly report progress #13079

Merged

Conversation

Empact
Copy link
Member

@Empact Empact commented Apr 25, 2018

Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

RescanVerificationProgress(const CWallet& wallet, const CBlockIndex* const stop_block)
: m_wallet(wallet), m_time(GetTime()), m_stop_block(stop_block) {}

void Start(const CBlockIndex* const start_block)
Copy link
Contributor

Choose a reason for hiding this comment

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

simpler to RAII this instead of a separate Constructor/Start/AnnounceStart methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

The main reason I kept this separate is that GuessVerificationProgress needs cs_main held, and I wanted to minimize the amount of code in the lock-block.

@Empact Empact force-pushed the scan-for-wallet-stopblock-progress branch from b5fe7a2 to 409db40 Compare April 30, 2018 07:03
@Empact Empact changed the title Fix ScanForWalletTransactions to report progress correctly when a pindexStop is supplied Fix rescanblockchain rpc to property report progress Apr 30, 2018
@Empact
Copy link
Member Author

Empact commented Apr 30, 2018

Removed the refactoring for easier review.

@jonasschnelli
Copy link
Contributor

Makes sense. Reporting progress for partial rescans based on the given range seems to be more logical.
utACK 409db40b6f56748a5b1713a0bc117a8365d9f3ef

@@ -1742,9 +1742,13 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
double dProgressTip;
Copy link
Member

Choose a reason for hiding this comment

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

should probably be called progress_end

dProgressStart = GuessVerificationProgress(chainParams.TxData(), pindex);
dProgressTip = GuessVerificationProgress(chainParams.TxData(), tip);
if (pindexStop == nullptr) {
tip = chainActive.Tip()
Copy link
Member

@maflcko maflcko Apr 30, 2018

Choose a reason for hiding this comment

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

missing semicolon, also wrong indentation.

@maflcko
Copy link
Member

maflcko commented Apr 30, 2018

utACK 409db40

@laanwj
Copy link
Member

laanwj commented Apr 30, 2018

From travis:

wallet/wallet.cpp: In member function ‘CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex*, CBlockIndex*, const WalletRescanReserver&, bool)’:
wallet/wallet.cpp:1748:15: error: expected ‘;’ before ‘dProgressTip’
               dProgressTip = GuessVerificationProgress(chainParams.TxData(), tip);
               ^

@Empact Empact force-pushed the scan-for-wallet-stopblock-progress branch from 409db40 to d700433 Compare April 30, 2018 14:29
@Empact
Copy link
Member Author

Empact commented Apr 30, 2018

Added semicolon, renamed progress vars to progress_*, and clang-formatted.

@Empact Empact changed the title Fix rescanblockchain rpc to property report progress Fix rescanblockchain rpc to properly report progress Apr 30, 2018
CWallet::ScanForWalletTransactions did not previously take into account
pindexStop when calculating progress.

Renamed progress vars to progress_*.

rescanblockchain is the only rpc that uses this parameter.
@Empact Empact force-pushed the scan-for-wallet-stopblock-progress branch from d700433 to 16be133 Compare May 3, 2018 17:19
@Empact
Copy link
Member Author

Empact commented May 3, 2018

Rebased

@TheBlueMatt
Copy link
Contributor

utACK 16be133

1 similar comment
@maflcko
Copy link
Member

maflcko commented May 6, 2018

utACK 16be133

@jonasschnelli
Copy link
Contributor

Tested ACK 16be133

@jonasschnelli jonasschnelli merged commit 16be133 into bitcoin:master May 7, 2018
jonasschnelli added a commit that referenced this pull request May 7, 2018
16be133 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40
@promag
Copy link
Member

promag commented May 7, 2018

utACK 16be133.

@Empact Empact deleted the scan-for-wallet-stopblock-progress branch May 7, 2018 14:52
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 27, 2019
Summary:
16be133 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40

Backport of Core PR13079
bitcoin/bitcoin#13079

Test Plan:
  make check
  ./bitcoind --printtoconsole
  ./bitcoin-cli rescanblockchain 0 1300000

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, Fabien, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4112
jonspock pushed a commit to jonspock/devault that referenced this pull request Dec 24, 2019
Summary:
16be13345 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40

Backport of Core PR13079
bitcoin/bitcoin#13079

Test Plan:
  make check
  ./bitcoind --printtoconsole
  ./bitcoin-cli rescanblockchain 0 1300000

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, Fabien, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4112
jonspock pushed a commit to jonspock/devault that referenced this pull request Dec 26, 2019
Summary:
16be13345 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40

Backport of Core PR13079
bitcoin/bitcoin#13079

Test Plan:
  make check
  ./bitcoind --printtoconsole
  ./bitcoin-cli rescanblockchain 0 1300000

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, Fabien, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4112
jonspock pushed a commit to devaultcrypto/devault that referenced this pull request Dec 27, 2019
Summary:
16be13345 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40

Backport of Core PR13079
bitcoin/bitcoin#13079

Test Plan:
  make check
  ./bitcoind --printtoconsole
  ./bitcoin-cli rescanblockchain 0 1300000

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, Fabien, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4112
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 17, 2020
…ress

16be133 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 27, 2020
…ress

16be133 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 28, 2020
…ress

16be133 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40
Copy link

@karra75 karra75 left a comment

Choose a reason for hiding this comment

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

U

Copy link

@karra75 karra75 left a comment

Choose a reason for hiding this comment

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

Sorce

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants