Skip to content

Conversation

Empact
Copy link
Contributor

@Empact Empact commented Dec 13, 2018

By returning ScanResult from RescanFromTime and reporting the effectuality of AbortScan.

And consolidate rpc-level error handling across RescanFromTime and
ScanForWalletTransactions.

Note this changes the rescanblockchain scan failure error from
RPC_MISC_ERROR to RPC_WALLET_ERROR, which seems more appropriate and matches the
behavior from the rpcdump methods.

This follows up on #13076.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 13, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@Empact Empact changed the title Wallet: Return a ScanResult from CWallet::RescanFromTime wallet: Return a ScanResult from CWallet::RescanFromTime Dec 14, 2018
@Empact Empact force-pushed the rescan-from-time-result branch from a71986a to 94accf9 Compare January 31, 2019 01:12
@Empact Empact changed the title wallet: Return a ScanResult from CWallet::RescanFromTime wallet: Make scan / abort status private to CWallet Jan 31, 2019
@Empact
Copy link
Contributor Author

Empact commented Jan 31, 2019

Rebased and substantially refocused this PR to:

  • Return ScanResult from RescanFromTime
  • Add ScanResult::FailedTime to report the best non-failing time - beneficial also because most callers are uninterested in the time
  • Drop IsScanning and IsAbortingRescan from CWallet, as all scan/abort status is now returned as results from specific operations.

@Empact Empact force-pushed the rescan-from-time-result branch 3 times, most recently from fd61c8b to 4cfd0a8 Compare February 2, 2019 10:15
@Empact Empact force-pushed the rescan-from-time-result branch from 4cfd0a8 to 9d6a502 Compare February 8, 2019 22:27
@Empact Empact force-pushed the rescan-from-time-result branch from 9d6a502 to 741f2fe Compare April 3, 2019 04:47
@Empact Empact force-pushed the rescan-from-time-result branch from 741f2fe to 4b4cf7c Compare April 14, 2019 03:58
@Empact
Copy link
Contributor Author

Empact commented Apr 14, 2019

Rebased

@jb55
Copy link
Contributor

jb55 commented May 14, 2019

looks like a nice refactor

utACK 4b4cf7c

@Empact Empact force-pushed the rescan-from-time-result branch from 4b4cf7c to 469117d Compare May 17, 2019 02:58
@Empact
Copy link
Contributor Author

Empact commented May 17, 2019

Rebased, and restored IsScanning as it's needed for d3e8458

@jb55
Copy link
Contributor

jb55 commented May 17, 2019

not sure why github tends to screw up range-diffs sometimes but here's the last one:

$ git range-diff 4b4cf7c~2..4b4cf7c 469117d~2..469117d
1:  99a72728a6 = 1:  c82f6c7806 Return ScanResult from CWallet::RescanFromTime
2:  4b4cf7cc28 ! 2:  469117d55c Make scan / abort status private to CWallet
@@ -2,7 +2,7 @@
 
     Make scan / abort status private to CWallet
 
-    Drop CWallet::IsAbortingRescan and IsScanning by reporting the abort
+    Drop CWallet::IsAbortingRescan by reporting the abort
     effectuality from CWallet::AbortScan.
 
  diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
@@ -54,8 +54,7 @@
       */
 -    void AbortRescan() { fAbortRescan = true; }
 -    bool IsAbortingRescan() { return fAbortRescan; }
--    bool IsScanning() { return fScanningWallet; }
 +    bool AbortRescan();
- 
-     /**
-      * keystore implementation
+     bool IsScanning() { return fScanningWallet; }
+     int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
+     double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }

re-utACK 469117d

@Empact Empact force-pushed the rescan-from-time-result branch from 469117d to c26c232 Compare January 17, 2020 02:35
Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

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

Looks like an improvement. Left comments.

* exist in the wallet will be updated.
*
* @param[in] start_block Scan starting block. If block is not on the active
* chain, the scan will return SUCCESS immediately.
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels weird to me, and feels like it should have a new ORPHAN_CHAIN ScanResult, even if this is handled the same way as SUCCESS everywhere right now.

@@ -169,6 +169,13 @@ std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string&
return LoadWallet(chain, WalletLocation(name), error, warnings);
}

bool CWallet::AbortRescan()
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you could have a race in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a bit convoluted, but I think it's handled gracefully: if fScanningWallet is set to false as fAbortRescan is being set to true (i.e. at the end of a scan), there is no issue as ScanForWalletTransactions sets fAbortRescan to false at its start.

BTW this behavior is unchanged - here's the prior implementation: https://github.com/bitcoin/bitcoin/pull/14942/files#diff-522490d83dce5375d423b23886e4125eL217-R219

if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) return false;
pwallet->AbortRescan();
return true;
return pwallet->AbortRescan();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does it matter the return value? Isn't even documented.

Empact added 3 commits March 10, 2020 12:53
Lookup the failed time just in the case it's needed.
Drop CWallet::IsAbortingRescan by reporting the abort
effectuality from CWallet::AbortScan.
@Empact Empact force-pushed the rescan-from-time-result branch from 319aeba to 71b9360 Compare March 11, 2020 18:15
@DrahtBot DrahtBot mentioned this pull request Mar 20, 2020
@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@laanwj
Copy link
Member

laanwj commented Sep 9, 2021

Any plans for this? It's needed rebase for more than a year, no other activity.

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?
  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@maflcko maflcko closed this Dec 22, 2021
@maflcko
Copy link
Member

maflcko commented Dec 22, 2021

Closing for now due to inactivity for more than a year. Can be reopened anytime. Just leave a comment here or in IRC.

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

Successfully merging this pull request may close these issues.

10 participants