Fix Qt shutdown and Linux wallet build
This commit is contained in:
+6
-2
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "amount.h"
|
||||
#include "hash.h"
|
||||
#include "init.h"
|
||||
#include "main.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "net.h"
|
||||
@@ -634,7 +635,7 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake)
|
||||
CReserveKey reservekey(pwallet);
|
||||
unsigned int nExtraNonce = 0;
|
||||
bool fLastLoopOrphan = false;
|
||||
while (fGenerateBitcoins || fProofOfStake) {
|
||||
while ((fGenerateBitcoins || fProofOfStake) && !ShutdownRequested()) {
|
||||
if (fProofOfStake) {
|
||||
//control the amount of times the client will check for mintable coins
|
||||
if ((GetTime() - nMintableLastCheck > 5 * 60)) // 5 minute check time
|
||||
@@ -648,7 +649,7 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake)
|
||||
continue;
|
||||
}
|
||||
|
||||
while (vNodes.empty() || pwallet->IsLocked() || !fMintableCoins || (pwallet->GetBalance() > 0 && nReserveBalance >= pwallet->GetBalance()) || !masternodeSync.IsSynced()) {
|
||||
while (!ShutdownRequested() && (vNodes.empty() || pwallet->IsLocked() || !fMintableCoins || (pwallet->GetBalance() > 0 && nReserveBalance >= pwallet->GetBalance()) || !masternodeSync.IsSynced())) {
|
||||
nLastCoinStakeSearchInterval = 0;
|
||||
// Do a separate 1 minute check here to ensure fMintableCoins is updated
|
||||
if (!fMintableCoins) {
|
||||
@@ -662,6 +663,8 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake)
|
||||
if (!fGenerateBitcoins && !fProofOfStake)
|
||||
continue;
|
||||
}
|
||||
if (ShutdownRequested())
|
||||
break;
|
||||
|
||||
if (mapHashedBlocks.count(chainActive.Tip()->nHeight) && !fLastLoopOrphan) //search our map of hashed blocks, see if bestblock has been hashed yet
|
||||
{
|
||||
@@ -834,6 +837,7 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
|
||||
|
||||
if (minerThreads != nullptr) {
|
||||
minerThreads->interrupt_all();
|
||||
minerThreads->join_all();
|
||||
delete minerThreads;
|
||||
minerThreads = nullptr;
|
||||
}
|
||||
|
||||
+4
-2
@@ -278,8 +278,9 @@ void BitcoinCore::restart(QStringList args)
|
||||
qDebug() << __func__ << ": Running Restart in thread";
|
||||
Interrupt();
|
||||
PrepareShutdown();
|
||||
qDebug() << __func__ << ": Shutdown finished";
|
||||
emit shutdownResult(1);
|
||||
QMetaObject::invokeMethod(QApplication::instance(), "quit", Qt::QueuedConnection);
|
||||
QApplication::exit(0);
|
||||
CExplicitNetCleanup::callCleanup();
|
||||
QProcess::startDetached(QApplication::applicationFilePath(), args);
|
||||
qDebug() << __func__ << ": Restart initiated...";
|
||||
@@ -298,8 +299,9 @@ void BitcoinCore::shutdown()
|
||||
qDebug() << __func__ << ": Running Shutdown in thread";
|
||||
Interrupt();
|
||||
Shutdown();
|
||||
qDebug() << __func__ << ": Shutdown finished";
|
||||
emit shutdownResult(1);
|
||||
QMetaObject::invokeMethod(QApplication::instance(), "quit", Qt::QueuedConnection);
|
||||
QApplication::exit(0);
|
||||
} catch (std::exception& e) {
|
||||
handleRunawayException(&e);
|
||||
} catch (...) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "wallet/walletdb.h"
|
||||
|
||||
#include "base58.h"
|
||||
#include "init.h"
|
||||
#include "protocol.h"
|
||||
#include "serialize.h"
|
||||
#include "sync.h"
|
||||
@@ -916,7 +917,7 @@ void ThreadFlushWalletDB(const string& strFile)
|
||||
unsigned int nLastSeen = nWalletDBUpdated;
|
||||
unsigned int nLastFlushed = nWalletDBUpdated;
|
||||
int64_t nLastWalletUpdate = GetTime();
|
||||
while (true) {
|
||||
while (!ShutdownRequested()) {
|
||||
MilliSleep(500);
|
||||
|
||||
if (nLastSeen != nWalletDBUpdated) {
|
||||
|
||||
Reference in New Issue
Block a user