Skip to content

Commit

Permalink
Merge #2228: Fixing few shutdown problems
Browse files Browse the repository at this point in the history
c853471 init: shutdown and return early if ActivateBestChain() fails. (furszy)
1961163 qt: Poll ShutdownTimer after init is done (Marco)
21d56e7 [GUI] Topbar: don't try to poll for data if shutdown was requested. (furszy)

Pull request description:

  First commit was decoupled from #2131, the topbar staking status polling should not try to refresh data if shutdown was requested.
  Second commit is coming from bitcoin#12377.
  Third commit is starting the shutdown process and returning early (without starting the import thread) if the best chain cannot be activated during the node's initialization.

ACKs for top commit:
  random-zebra:
    utACK c853471
  Fuzzbawls:
    utACK c853471

Tree-SHA512: 8d5b289df0ba30d5f654b702e49b01127aa2470550d1313ed63022b0e6c737b3d092a50bd9caf759ea1308f20b6bab65a2a01ff89e7758e50826d389b257e16b
  • Loading branch information
random-zebra committed Mar 6, 2021
2 parents 7fa2f89 + c853471 commit 1fbf681
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1793,8 +1793,11 @@ bool AppInitMain()

// scan for better chains in the block chain database, that are not yet connected in the active best chain
CValidationState state;
if (!ActivateBestChain(state))
if (!ActivateBestChain(state)) {
strErrors << "Failed to connect best block";
StartShutdown();
return false;
}
// update g_best_block if needed
{
LOCK(g_best_block_mutex);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ void BitcoinApplication::createWindow(const NetworkStyle* networkStyle)

pollShutdownTimer = new QTimer(window);
connect(pollShutdownTimer, &QTimer::timeout, window, &PIVXGUI::detectShutdown);
pollShutdownTimer->start(200);
}

void BitcoinApplication::createSplashScreen(const NetworkStyle* networkStyle)
Expand Down Expand Up @@ -514,6 +513,7 @@ void BitcoinApplication::initializeResult(int retval)
});
QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady);
#endif
pollShutdownTimer->start(200);
} else {
quit(); // Exit main loop
}
Expand Down
11 changes: 6 additions & 5 deletions src/qt/pivx/topbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,13 @@ void TopBar::setStakingStatusActive(bool fActive)
}
void TopBar::updateStakingStatus()
{
setStakingStatusActive(walletModel &&
!walletModel->isWalletLocked() &&
walletModel->isStakingStatusActive());
if (walletModel && !walletModel->isShutdownRequested()) {
setStakingStatusActive(!walletModel->isWalletLocked() &&
walletModel->isStakingStatusActive());

// Taking advantage of this timer to update Tor status if needed.
updateTorIcon();
// Taking advantage of this timer to update Tor status if needed.
updateTorIcon();
}
}

void TopBar::setNumConnections(int count)
Expand Down
6 changes: 6 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "optionsmodel.h"
#include "recentrequeststablemodel.h"
#include "transactiontablemodel.h"
#include "init.h" // for ShutdownRequested(). Future: move to an interface wrapper

#include "base58.h"
#include "coincontrol.h"
Expand Down Expand Up @@ -67,6 +68,11 @@ bool WalletModel::isRegTestNetwork() const
return Params().IsRegTestNet();
}

bool WalletModel::isShutdownRequested()
{
return ShutdownRequested();
}

bool WalletModel::isColdStakingNetworkelyEnabled() const
{
return !sporkManager.IsSporkActive(SPORK_19_COLDSTAKING_MAINTENANCE);
Expand Down
1 change: 1 addition & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class WalletModel : public QObject

bool isTestNetwork() const;
bool isRegTestNetwork() const;
bool isShutdownRequested();
/** Whether cold staking is enabled or disabled in the network **/
bool isColdStakingNetworkelyEnabled() const;
bool isSaplingInMaintenance() const;
Expand Down

0 comments on commit 1fbf681

Please sign in to comment.