mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-14 22:02:37 -03:00
Wallet: Let the interval-flushing thread figure out the filename
This commit is contained in:
parent
bfc7aad008
commit
fb0c934d1b
4 changed files with 11 additions and 3 deletions
|
@ -3549,6 +3549,8 @@ bool CWallet::InitLoadWallet()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::atomic<bool> CWallet::fFlushThreadRunning(false);
|
||||||
|
|
||||||
void CWallet::postInitProcess(boost::thread_group& threadGroup)
|
void CWallet::postInitProcess(boost::thread_group& threadGroup)
|
||||||
{
|
{
|
||||||
// Add wallet transactions that aren't already in a block to mempool
|
// Add wallet transactions that aren't already in a block to mempool
|
||||||
|
@ -3556,7 +3558,9 @@ void CWallet::postInitProcess(boost::thread_group& threadGroup)
|
||||||
ReacceptWalletTransactions();
|
ReacceptWalletTransactions();
|
||||||
|
|
||||||
// Run a thread to flush wallet periodically
|
// Run a thread to flush wallet periodically
|
||||||
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(this->strWalletFile)));
|
if (!CWallet::fFlushThreadRunning.exchange(true)) {
|
||||||
|
threadGroup.create_thread(ThreadFlushWalletDB);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::ParameterInteraction()
|
bool CWallet::ParameterInteraction()
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "wallet/rpcwallet.h"
|
#include "wallet/rpcwallet.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <atomic>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -550,6 +551,8 @@ private:
|
||||||
class CWallet : public CCryptoKeyStore, public CValidationInterface
|
class CWallet : public CCryptoKeyStore, public CValidationInterface
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
static std::atomic<bool> fFlushThreadRunning;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select a set of coins such that nValueRet >= nTargetValue and at least
|
* Select a set of coins such that nValueRet >= nTargetValue and at least
|
||||||
* all coins from coinControl are selected; Never select unconfirmed coins
|
* all coins from coinControl are selected; Never select unconfirmed coins
|
||||||
|
|
|
@ -768,7 +768,7 @@ DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector<CWalletTx>& vWtx)
|
||||||
return DB_LOAD_OK;
|
return DB_LOAD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadFlushWalletDB(const string& strFile)
|
void ThreadFlushWalletDB()
|
||||||
{
|
{
|
||||||
// Make this thread recognisable as the wallet flushing thread
|
// Make this thread recognisable as the wallet flushing thread
|
||||||
RenameThread("bitcoin-wallet");
|
RenameThread("bitcoin-wallet");
|
||||||
|
@ -810,6 +810,7 @@ void ThreadFlushWalletDB(const string& strFile)
|
||||||
if (nRefCount == 0)
|
if (nRefCount == 0)
|
||||||
{
|
{
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
|
const std::string& strFile = pwalletMain->strWalletFile;
|
||||||
map<string, int>::iterator _mi = bitdb.mapFileUseCount.find(strFile);
|
map<string, int>::iterator _mi = bitdb.mapFileUseCount.find(strFile);
|
||||||
if (_mi != bitdb.mapFileUseCount.end())
|
if (_mi != bitdb.mapFileUseCount.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -182,6 +182,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void ThreadFlushWalletDB(const std::string& strFile);
|
void ThreadFlushWalletDB();
|
||||||
|
|
||||||
#endif // BITCOIN_WALLET_WALLETDB_H
|
#endif // BITCOIN_WALLET_WALLETDB_H
|
||||||
|
|
Loading…
Reference in a new issue