Skip to content

Commit

Permalink
better progress reporting for wallet rebuilding
Browse files Browse the repository at this point in the history
  • Loading branch information
BreakoutCoin committed Feb 11, 2022
1 parent 510cf44 commit 74271d3
Show file tree
Hide file tree
Showing 16 changed files with 347 additions and 163 deletions.
6 changes: 3 additions & 3 deletions breakout-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ win32 {

TEMPLATE = app
TARGET = "Breakout-Coin"
VERSION = 1.6.4.0
VERSION = 1.6.5.0
INCLUDEPATH += src src/json src/qt src/tor
INCLUDEPATH += src/tor/adapter src/tor/common src/tor/ext
INCLUDEPATH += src/tor/ext/curve25519_donna src/tor/ext/ed25519/donna
Expand Down Expand Up @@ -67,7 +67,7 @@ win32 {
contains(WINBITS, 32) {
INCLUDEPATH += C:/$$MSYS/local/boost_1_57_0/
} else {
INCLUDEPATH += C:/$$MSYS/usr/local/include/boost-1_57/
INCLUDEPATH += C:/$$MSYS/usr/local/include/boost-1_65_1/
}
}

Expand Down Expand Up @@ -881,7 +881,7 @@ isEmpty(BOOST_LIB_SUFFIX) {
contains(WINBITS, 32) {
BOOST_LIB_SUFFIX = -mgw49-mt-s-1_57
} else {
BOOST_LIB_SUFFIX = -mgw102-mt-1_57
BOOST_LIB_SUFFIX = -mgw102-mt-1_65_1
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions contrib/macdeploy/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleGetInfoString</key>
<string>Breakout Chain [BRK/BRX] Multicurrency 1.6.4.0</string>
<string>Breakout Chain [BRK/BRX] Multicurrency 1.6.5.0</string>
<key>CFBundleExecutable</key>
<string>Breakout-Coin</string>
<key>CFBundleIdentifier</key>
<string>com.breakoutcoin.breakout-qt</string>
<key>CFBundleShortVersionString</key>
<string>1.6.4.0</string>
<string>1.6.5.0</string>
<key>CFBundleSignature</key>
<string>BroX</string>
<key>CFBundleVersion</key>
<string>1.6.4.0</string>
<string>1.6.5.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 6
#define CLIENT_VERSION_REVISION 4
#define CLIENT_VERSION_REVISION 5
#define CLIENT_VERSION_BUILD 0

// Converts the parameter X to a string after macro replacement on X has been performed.
Expand Down
4 changes: 3 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,9 @@ bool AppInit2()
uiInterface.InitMessage(_("Rescanning..."));
printf("Rescanning last %d blocks (from block %d)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
nStart = GetTimeMillis();
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
string strProgressLabel("Progress of ScanForWalletTransactions");
CProgressHelper progress(&stdOutProgress, &strProgressLabel, 1000);
pwalletMain->ScanForWalletTransactions(pindexRescan, true, progress);
printf(" rescan %15" PRId64 "ms\n", GetTimeMillis() - nStart);
}

Expand Down
105 changes: 74 additions & 31 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
extern CWallet* pwalletMain;
extern int64_t nLastCoinStakeSearchInterval;
extern unsigned int nTargetSpacing;

extern void StartShutdown();

double GetPoSKernelPS();

// unpack dates in this format: ["1/15/2015", "7/19/2014"]
Expand Down Expand Up @@ -382,8 +385,8 @@ void BitcoinGUI::createActions()
#endif
backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
backupWalletAction->setToolTip(tr("Backup wallet to another location"));
updateWalletAction = new QAction(QIcon(":/icons/options"), tr("&Rebuild Wallet"), this);
updateWalletAction->setToolTip(tr("Purge and re-scan wallet"));
rebuildWalletAction = new QAction(QIcon(":/icons/options"), tr("&Rebuild Wallet"), this);
rebuildWalletAction->setToolTip(tr("Purge and re-scan wallet"));
changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
unlockWalletAction = new QAction(QIcon(":/icons/mint_closed"), tr("&Unlock Wallet"), this);
Expand All @@ -409,7 +412,7 @@ void BitcoinGUI::createActions()
connect(importWalletAction, SIGNAL(triggered()), this, SLOT(importWallet()));
#endif
connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
connect(updateWalletAction, SIGNAL(triggered()), this, SLOT(updateWallet()));
connect(rebuildWalletAction, SIGNAL(triggered()), this, SLOT(rebuildWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
connect(unlockWalletAction, SIGNAL(triggered()), this, SLOT(unlockWallet()));
connect(lockWalletAction, SIGNAL(triggered()), this, SLOT(lockWallet()));
Expand All @@ -431,7 +434,7 @@ void BitcoinGUI::createMenuBar()
// Configure the menus
QMenu *file = appMenuBar->addMenu(tr("&File"));
file->addAction(backupWalletAction);
file->addAction(updateWalletAction);
file->addAction(rebuildWalletAction);
file->addAction(exportAction);
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
Expand Down Expand Up @@ -1330,11 +1333,18 @@ void BitcoinGUI::backupWallet()
}
}

void BitcoinGUI::updateWallet()
void dialogProgress(void *d, unsigned int v)
{
static_cast<QProgressDialog*>(d)->setValue(v);
}


void BitcoinGUI::rebuildWallet()
{
{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Backup First", "Backup wallet first? (Recommended)",
reply = QMessageBox::question(this, "Breakout Chain",
"Backup wallet first? (Recommended)",
QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes) {
this->backupWallet();
Expand All @@ -1343,7 +1353,8 @@ void BitcoinGUI::updateWallet()

{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Rebuild", "Rebuilding takes a lot of time, proceed?",
reply = QMessageBox::question(this, "Breakout Chain",
"Rebuilding takes a lot of time, proceed?",
QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::No) {
return;
Expand All @@ -1353,39 +1364,71 @@ void BitcoinGUI::updateWallet()

MilliSleep(10);

QProgressDialog dialog("Re-Scanning. Please wait...", "Cancel", 0, 100, this);
dialog.setWindowModality(Qt::WindowModal);
dialog.setCancelButton(0);
dialog.setMinimumDuration(0);
dialog.show();
{
QProgressDialog dialog("Rescan - Clearing wallet transactions. "
"Please wait.",
"Cancel", 0, 100, this);
dialog.setWindowModality(Qt::WindowModal);
dialog.setCancelButton(0);
dialog.setMinimumDuration(0);
dialog.setValue(0);
dialog.show();

CBlockIndex *pindex = pindexGenesisBlock;
if (pindex == NULL) {
// no reason to notify user (?)
return;
}

CBlockIndex *pindex = pindexGenesisBlock;
if (pindex == NULL) {
// no reason to notify user (?)
return;
}
// Updating after every change takes a long time.
if (walletModel)
{
walletModel->unsubscribeFromTransactionSignal();
}

// MilliSleep(10);
dialog.setValue(0);
// MilliSleep(10);
CProgressHelper progress(&dialogProgress, &dialog, 100);

clearwallettransactions(json_spirit::Array(), false);
{

dialog.setValue(1);
// MilliSleep(10);
LOCK2(cs_main, pwalletMain->cs_wallet);

{
LOCK2(cs_main, pwalletMain->cs_wallet);
std::string strError;
pwalletMain->ClearWalletTransactions(strError, progress);

dialog.setLabelText("Rescan - Scanning for wallet transactions. "
"Please wait.");
progress.setEvery(1000);

pwalletMain->MarkDirty();

pwalletMain->ScanForWalletTransactions(pindex,
true,
progress);

dialog.setLabelText("Rescan - Reaccepting wallet transactions. "
"Please wait.");
progress.setEvery(100);

pwalletMain->MarkDirty();
pwalletMain->ReacceptWalletTransactions(progress);
}

if (walletModel)
{
walletModel->subscribeToTransactionSignal();
}

dialog.setValue(30);
pwalletMain->ScanForWalletTransactions(pindex, true);
dialog.setValue(35);
pwalletMain->ReacceptWalletTransactions();
dialog.setValue(100);
}

dialog.setValue(100);
{
QMessageBox::StandardButton reply;
reply = QMessageBox::information(
this,
"Breakout Chain",
"Breakout Chain must quit to rebuild the transaction table.",
QMessageBox::Ok);
StartShutdown();
}
}

void BitcoinGUI::changePassphrase()
Expand Down
4 changes: 2 additions & 2 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class BitcoinGUI : public QMainWindow
#endif
QAction *getPrivkeysAction;
QAction *backupWalletAction;
QAction *updateWalletAction;
QAction *rebuildWalletAction;
QAction *changePassphraseAction;
QAction *unlockWalletAction;
QAction *lockWalletAction;
Expand Down Expand Up @@ -198,7 +198,7 @@ private slots:
/** Backup the wallet */
void backupWallet();
/** Clear and rescan wallet with optional backup */
void updateWallet();
void rebuildWallet();
/** Change encrypted wallet passphrase */
void changePassphrase();
/** Ask for passphrase to unlock wallet temporarily */
Expand Down
9 changes: 9 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,15 @@ static void NotifyBlocksChanged(WalletModel *walletmodel)
}
}

void WalletModel::subscribeToTransactionSignal()
{
wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
}

void WalletModel::unsubscribeFromTransactionSignal()
{
wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
}

void WalletModel::subscribeToCoreSignals()
{
Expand Down
3 changes: 3 additions & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class WalletModel : public QObject
// Wallet backup
bool backupWallet(const QString &filename);

void subscribeToTransactionSignal();
void unsubscribeFromTransactionSignal();

// RAI object for unlocking wallet, returned by requestUnlock()
class UnlockContext
{
Expand Down
8 changes: 6 additions & 2 deletions src/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,12 @@ Value importaddress(const Array& params, bool fHelp)
// whenever a key is imported, we need to scan the whole chain
pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value'

pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
pwalletMain->ReacceptWalletTransactions();
string strProgressLabel("Progress of ScanForWalletTransactions");
CProgressHelper progress(&stdErrProgress, &strProgressLabel, 1000);
pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true, progress);
strProgressLabel = "Progress of ReacceptWalletTransactions";
progress.setContext(&strProgressLabel);
pwalletMain->ReacceptWalletTransactions(progress);
}
}

Expand Down
Loading

0 comments on commit 74271d3

Please sign in to comment.