From bc356b4268e222ac57d9e9297d2a986bb6e09de8 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Tue, 12 Dec 2017 13:13:58 -1000 Subject: Make sure WalletRescanReserver has successfully reserved the rescan --- src/wallet/wallet.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 5d782faa60..70ced30e45 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -659,6 +659,7 @@ private: }; +class WalletRescanReserver; //forward declarations for ScanForWalletTransactions/RescanFromTime /** * A CWallet is an extension of a keystore, which also maintains a set of transactions and balances, * and provides the ability to create new transactions. @@ -668,7 +669,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface private: static std::atomic fFlushScheduled; std::atomic fAbortRescan; - std::atomic fScanningWallet; + std::atomic fScanningWallet; //controlled by WalletRescanReserver std::mutex mutexScanning; friend class WalletRescanReserver; @@ -948,8 +949,8 @@ public: void BlockConnected(const std::shared_ptr& pblock, const CBlockIndex *pindex, const std::vector& vtxConflicted) override; void BlockDisconnected(const std::shared_ptr& pblock) override; bool AddToWalletIfInvolvingMe(const CTransactionRef& tx, const CBlockIndex* pIndex, int posInBlock, bool fUpdate); - int64_t RescanFromTime(int64_t startTime, bool update); - CBlockIndex* ScanForWalletTransactions(CBlockIndex* pindexStart, CBlockIndex* pindexStop, bool fUpdate = false); + int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update); + CBlockIndex* ScanForWalletTransactions(CBlockIndex* pindexStart, CBlockIndex* pindexStop, const WalletRescanReserver& reserver, bool fUpdate = false); void TransactionRemovedFromMempool(const CTransactionRef &ptx) override; void ReacceptWalletTransactions(); void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) override; @@ -1287,6 +1288,11 @@ public: return true; } + bool isReserved() const + { + return (m_could_reserve && m_wallet->fScanningWallet); + } + ~WalletRescanReserver() { std::lock_guard lock(m_wallet->mutexScanning); -- cgit v1.2.3