achow101
commented at 0:41 am on August 31, 2017:
member
A cancel button is added to the showProgress dialog that is used only for rescans. When clicked, AbortRescan is called directly to cancel the rescan.
Rescans triggered from the debug console will now be cancelable by clicking the cancel button.
Rescans triggered by a command (e.g. importmulti) will now give an error indicating that the rescan was aborted by the user (either by the abortrescan command or by clicking cancel).
achow101 force-pushed
on Aug 31, 2017
achow101 force-pushed
on Aug 31, 2017
in
src/qt/bitcoingui.cpp:1134
in
e6e8b0c259outdated
ryanofsky
commented at 3:26 pm on August 31, 2017:
In commit “Add cancel function reference to ShowProgress”
A typedef or using declaration for std::function<void(void)> might make the changes throughout this commit be more readable, and also make this code less fragile because SIGNAL and SLOT macros rely on string comparison.
in
src/txdb.cpp:389
in
9fbc64546foutdated
385@@ -386,7 +386,7 @@ bool CCoinsViewDB::Upgrade() {
386 if (count++ % 256 == 0) {
387 uint32_t high = 0x100 * *key.second.begin() + *(key.second.begin() + 1);
388 int percentageDone = (int)(high * 100.0 / 65536.0 + 0.5);
389- uiInterface.ShowProgress(_("Upgrading UTXO database") + "\n"+ _("(press q to shutdown and continue later)") + "\n", percentageDone);
390+ uiInterface.ShowProgress(_("Upgrading UTXO database") + "\n"+ _("(press q to shutdown and continue later)") + "\n", percentageDone, std::function<void(void)>());
ryanofsky
commented at 4:05 pm on August 31, 2017:
In commit “Add cancel function reference to ShowProgress”
No need to write std::function<void(void)>() here and 12 other places. You can just pass {} or nullptr.
ryanofsky
commented at 6:54 pm on August 31, 2017:
member
utACKc8720f0a320eff0cc83a459dc87f28087d518825. Only changes were implementing various suggestions.
I’m not very fond of callbacks. Have you thought in alternatives?
Reason callback seems to be used is to avoid the need for qt code to call CWallet’s AbortRescan method or set the fAbortRescan flag directly. The alternatives would be for Qt to call a different function or set a different flag, but don’t seem like they would be much better or worse.
in
src/wallet/wallet.cpp:1571
in
c8720f0a32outdated
1567@@ -1568,13 +1568,13 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool f
1568 fAbortRescan = false;
1569 fScanningWallet = true;
15701571- ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
1572+ ShowProgress(_("Rescanning..."), 0, boost::bind(&CWallet::AbortRescan, this)); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
jonasschnelli
commented at 5:10 pm on September 3, 2017:
nit: use std::bind (and below)
achow101
commented at 7:51 pm on September 5, 2017:
Done
in
src/ui_interface.h:98
in
c8720f0a32outdated
94@@ -95,7 +95,7 @@ class CClientUIInterface
95 boost::signals2::signal<void (CWallet* wallet)> LoadWallet;
9697 /** Show progress e.g. for verifychain */
98- boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
99+ boost::signals2::signal<void (const std::string &title, int nProgress, const std::function<void(void)>& cancel)> ShowProgress;
jonasschnelli
commented at 5:12 pm on September 3, 2017:
use nullptr as default parameter for cancel to avoid adding nullptr to all non-callback ShowProgress calls?
achow101
commented at 5:11 pm on September 5, 2017:
I couldn’t set a default parameter in the signal, so I’m not sure it is possible to do that. Or I’m just doing something wrong.
jonasschnelli
commented at 5:12 pm on September 3, 2017:
contributor
Concept ACK
achow101 force-pushed
on Sep 5, 2017
laanwj added the label
GUI
on Sep 6, 2017
jonasschnelli
commented at 11:59 pm on September 6, 2017:
contributor
Tested a bit and there is a concurrency issue (maybe not related to this code but since you finally can test multiple rescans during the same runtime this PR may reveal the issue):
Sometimes the progress window does not show up (happened to me only if I canceled a rescan before) and the GUI is fully in locked state (due to the rescan).
In that case, the rescan is happening and the GUI is locked (without showing a progress screen) via cs_main in transactiontablemodel.cpp
jonasschnelli
commented at 5:17 pm on September 7, 2017:
contributor
Needs rebase
achow101 force-pushed
on Sep 7, 2017
achow101 force-pushed
on Sep 7, 2017
in
src/qt/bitcoingui.cpp:490
in
cb49c4fa5boutdated
ryanofsky
commented at 7:01 pm on October 12, 2017:
You added both resume_possible and cancel arguments to the ShowProgress signal in wallet.h so this should be _3, _4, instead of false, _4.
(Another alternative if you want to ensure wallet resume_possible value is always false, is to not add resume_possible in wallet.h, and then change this to false, _3. But adding the argument and then silently ignoring like this does now isn’t good.)
achow101
commented at 6:21 pm on October 31, 2017:
Done
achow101
commented at 6:40 pm on October 31, 2017:
Actually changing this seems to be causing a segfault, so I will leave it as is.
MarcoFalke
commented at 9:20 pm on March 18, 2018:
The following diff appears to be working for me. Could you help me find the steps to reproduce the segfault? Otherwise, I think this is a sensible suggestion.
Hmm, that diff works for me. I don’t remember what I did that caused a segfault. Added this change.
ryanofsky
commented at 7:04 pm on October 12, 2017:
member
utACK4657e40f1516d506095f969dc726da6f97d57a99. Only change since last review is rebase and some whitespace diffs.
promag
commented at 8:53 pm on October 29, 2017:
member
utACK4657e40. Have you thought adding tests for the new RPC errors? (might be impossible?)
jonasschnelli
commented at 9:53 pm on October 29, 2017:
contributor
Reminder: this PR currently causes a deadlock (at least on OSX):
IMO it would require #11281 to work flawless.
ryanofsky
commented at 5:45 pm on October 31, 2017:
member
@jonasschnelli, I don’t see how this could be causing any deadlock that wasn’t occurring before. The cancel callback isn’t acquiring any locks, just updating an atomic<bool>. Are you sure there is a problem in the current version of this PR?
achow101
commented at 6:08 pm on October 31, 2017:
member
@ryanofsky I think it is more that a deadlock currently exists in the rescanning code which this PR makes more obvious and easier to hit.
achow101 force-pushed
on Oct 31, 2017
achow101 force-pushed
on Oct 31, 2017
ryanofsky
commented at 6:43 pm on October 31, 2017:
member
@ryanofsky I think it is more that a deadlock currently exists in the rescanning code which this PR makes more obvious and easier to hit.
I know that’s the claim, but I don’t understand what the deadlock is. What does the rescan code have to do with transactiontablemodel and why would shorter aborted scans cause more UI problems than longer full scans?
achow101 force-pushed
on Oct 31, 2017
achow101 force-pushed
on Oct 31, 2017
ryanofsky
commented at 8:15 pm on October 31, 2017:
member
utACK449dd52b417d2a49b4de4440b391f6ebccb093b4. Same as before, just gets rid of spurious whitespace changes and void(void)
promag
commented at 7:48 am on December 5, 2017:
member
MarcoFalke
commented at 10:56 pm on March 18, 2018:
Why is this check within the scope of the (scanned_time > TIMESTAMP_MIN) check? Wouldn’t the following make more sense:
0if (pwallet->IsAbortingRescan()) throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
1if (scanned_time > TIMESTAMP_MIN) throw JSONRPCError(RPC_WALLET_ERROR, "Rescan was unable to fully rescan the blockchain. Some transactions may be missing.");
MarcoFalke
commented at 10:57 pm on March 18, 2018:
member
utACKc18cfb8fe0e5de02471011bef0e37f0a6d5920e6, but needs feedback addressed.
achow101 force-pushed
on Mar 18, 2018
achow101 force-pushed
on Mar 18, 2018
MarcoFalke
commented at 11:52 pm on March 18, 2018:
member
re-utACK1de7f88f4cad0f59a6684e179177707c8efd7b3a (only changes were to address the feedback)
ryanofsky
commented at 3:29 pm on March 20, 2018:
member
utACK1de7f88f4cad0f59a6684e179177707c8efd7b3a. Changes since last review were rebase, checking for abort condition even if RescanFromTime succeeds, and forwarding resume_possible argument to showProgress.
MarcoFalke added the label
RPC/REST/ZMQ
on Mar 21, 2018
MarcoFalke
commented at 1:19 pm on March 21, 2018:
member
@jonasschnelli You tested this a bit last year. Mind to re-test?
achow101 force-pushed
on Mar 28, 2018
achow101
commented at 5:59 pm on March 28, 2018:
member
Rebased
TheBlueMatt
commented at 6:26 pm on March 28, 2018:
member
This effectively reverts #10770. Please, no. If you want a specific cancel function, please split out showprogress into an init version and a rescan version, passing up std::functions from everywhere (and across the uiInterface interface, which people are still talking about making a process boundary) is really, really, really gross.
achow101
commented at 6:35 pm on March 28, 2018:
member
@TheBlueMatt I don’t see any other way to implement such cancellations in the GUI. Perhaps you could suggest something?
TheBlueMatt
commented at 6:53 pm on March 28, 2018:
member
We cancel just fine during init already (using StartShutdown()). If we want to also support cancelling via a rescan progress dialog, the rescan progress dialog should know how to make that happen. I still really don’t think we need a generic interface here - we only use the dialog for one thing (and I’m not aware of any other cancelable proposed things to show there) - and making it common between init and rescan still makes no sense to me - they are very, very different things.
ryanofsky
commented at 7:09 pm on March 28, 2018:
member
@TheBlueMatt, your objection seems the same as the “I’m not very fond of callbacks” criticism which came up earlier: #11200#pullrequestreview-59957173. I didn’t think this was a big deal (or really a very substantive criticism), but it would be pretty easy to address by replacing the callback with a wallet AbortRescans() function that Qt code could call more directly. Would this make everybody happy?
TheBlueMatt
commented at 7:13 pm on March 28, 2018:
member
Its a bit more broad, I’m a bit more than “not fond of” passing callbacks from random internal places all the way to GUI, plus we started with that and deliberately got rid of them. Adding them back would need more justification than “well, this is a way that it can be done”.
ryanofsky
commented at 7:29 pm on March 28, 2018:
member
I think supporting cancelling rescans is a worthwhile feature, and there are lots of ways it can be implemented. Which way to choose is mostly a question of how much much existing code you want to rewrite.
Having qt code just call an AbortRescan function when the cancel button is pressed is probably the simplest possible approach. Having the qt code call a generic cancel callback is a little more generic, and maybe a little cleaner, but does involve callbacks. Changing the progress dialog to be aware of the differences between init and rescan would be another way to approach this, and probably a good idea, but just a larger change.
achow101 force-pushed
on Mar 31, 2018
achow101 force-pushed
on Mar 31, 2018
achow101
commented at 8:06 pm on March 31, 2018:
member
I changed the implementation to completely remove the callback. The showProgress dialog that is used for rescans just calls AbortRescan directly when cancel is clicked. This should work since the dialog is used only for rescanning.
In commit “Give an error when rescan is aborted by the user”
This code is repeated 4 times, maybe it’s worth moving it to a function?
Could be nice, though to be honest a lot of other code is duplicated between the import* RPCs too. So effort might be better spent deduping larger chunks or deprecating older RPCs in favor of importmulti.
Would suggest renaming this method abortRescan and moving it above backupWallet (both here and in wallet.cpp). These interfaces are organized with regular methods on top and callback methods below. Also roughly with whole-wallet operations above operations on individual addresses and transactions.
In commit “Add cancel button to rescan progress dialog”
Would suggest dropping this method and just calling model.wallet().abortRescan() directly. I don’t think there’s a benefit to wrapping individual Wallet calls inside WalletModel methods unless they’re doing extra work like synchronization or caching.
promag
commented at 10:55 pm on April 8, 2018:
member
Some comments, will test later.
promag
commented at 10:58 pm on April 8, 2018:
member
Changing the progress dialog to be aware of the differences between init and rescan would be another way to approach this, and probably a good idea, but just a larger change.
I agree with @ryanofsky here. I’ll try to push #11826 forward. Not that this shouldn’t go forward.
jonasschnelli
commented at 4:37 pm on April 9, 2018:
contributor
Could finally test this.
I think it is an important feature because the way how users currently abort rescan is by force quitting the application (which is really not what we want).
Tested ACKbc2003cdf7102e03710dbc19e9c397b92e124fb4.
I’d like to see @promag’s nits addresses (lowercase methodname in QT, interface call via class member).
ryanofsky
commented at 4:47 pm on April 9, 2018:
member
utACKbc2003cdf7102e03710dbc19e9c397b92e124fb4. This PR has changed quite a lot since it was opened but is very simple at this point and provides useful functionality.
achow101 force-pushed
on Apr 9, 2018
in
src/wallet/rpcdump.cpp:557
in
5218cd3836outdated
533@@ -534,9 +534,9 @@ UniValue importwallet(const JSONRPCRequest& request)
534 int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
535 file.seekg(0, file.beg);
536537- pwallet->ShowProgress(_("Importing..."), 0); // show progress dialog in GUI
538+ uiInterface.ShowProgress(_("Importing..."), 0, false); // show progress dialog in GUI
In commit “Add cancel button to rescan progress dialog”
These changes from wallet to global ShowProgress calls seem unrelated. Are they intentional? It might make sense to change these if removing the wallet ShowProgress signal, but since that is still used in CWallet::ScanForWalletTransactions, this change just makes these calls inconsistent.
If this change is necessary it would be good to have a comment saying why CWallet::ShowProgress is not used here.
Because CWallet::ShowProgress has a cancel button now which is directly tied to AbortRescan (because it isn’t used for anything except showing rescan progress), I needed a different progress bar which does not have a cancel button. This change makes that ShowProgress use BitcoinGUI::ShowProgress (which is tied toe uiInterface)which does not have a cancel button (and is also not used anywhere else AFAICT). This progress bar indicates the import progress, not rescan progress which is why a different ShowProgress is needed
I added a comment.
ryanofsky
commented at 5:48 pm on April 9, 2018:
member
utACK66ee39f227b28a32c6c1cb6cd68c0eee0cc8637f
ryanofsky
commented at 7:10 pm on April 9, 2018:
member
utACKdeaffd812e3cdaeb7ec978c2d86f4bf688add96f, thanks for the comment!
Add cancel button to rescan progress dialog
Adds a cancel button to the rescan progress dialog. When it is clicked,
AbortRescan is called to abort a rescan
69b01e6f8b
Give an error when rescan is aborted by the userae1d2b0308
achow101 force-pushed
on Apr 12, 2018
achow101
commented at 9:00 pm on April 12, 2018:
member
Squashed the squashme. Is this ready for merging?
MarcoFalke
commented at 9:47 pm on April 12, 2018:
member
utACKae1d2b0308d7fe9df7fc18699c69e9587e6154bd. Going to test this later…
jonasschnelli merged this
on Apr 13, 2018
jonasschnelli closed this
on Apr 13, 2018
jonasschnelli referenced this in commit
5f2a39946f
on Apr 13, 2018
MarcoFalke removed this from the milestone 0.17.0
on Apr 21, 2018
MarcoFalke added this to the milestone 0.16.1
on Apr 21, 2018
MarcoFalke added the label
Needs backport
on Apr 21, 2018
MarcoFalke removed the label
Needs backport
on Apr 21, 2018
MarcoFalke removed this from the milestone 0.16.1
on Apr 21, 2018
Fabcien referenced this in commit
737142441b
on Aug 30, 2019
PastaPastaPasta referenced this in commit
ea808be82d
on Apr 13, 2020
UdjinM6 referenced this in commit
8ade2f7957
on Apr 14, 2020
PastaPastaPasta referenced this in commit
482c37308a
on Nov 10, 2020
PastaPastaPasta referenced this in commit
5fac392841
on Nov 12, 2020
PastaPastaPasta referenced this in commit
c0caa8ab32
on Nov 17, 2020
ckti referenced this in commit
448bc956f6
on Mar 28, 2021
gades referenced this in commit
d0be641481
on Jun 30, 2021
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2025-04-29 15:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me