diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-08-31 10:24:45 -0700 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-08-31 10:24:45 -0700 |
commit | cb6c4b883da6896b39bd46f845453f69d0f516f1 (patch) | |
tree | cc9de8e932d07cf2549a625e6c614a2677ec1b0e /src/wallet.h | |
parent | 21189a42a735ff66166c17c53eb44998346059d6 (diff) | |
parent | 471426fb3b2c2fa37640c03819c4f7be69ba8301 (diff) | |
download | bitcoin-cb6c4b883da6896b39bd46f845453f69d0f516f1.tar.xz |
Merge pull request #480 from gavinandresen/deadlocks
Simplify mutex locking, fix deadlocks. Fixes issue #453
Diffstat (limited to 'src/wallet.h')
-rw-r--r-- | src/wallet.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/wallet.h b/src/wallet.h index 499f2a63ac..032284dd3a 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -20,14 +20,14 @@ private: bool SelectCoins(int64 nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const; CWalletDB *pwalletdbEncryption; - CCriticalSection cs_pwalletdbEncryption; public: + mutable CCriticalSection cs_wallet; + bool fFileBacked; std::string strWalletFile; std::set<int64> setKeyPool; - CCriticalSection cs_setKeyPool; typedef std::map<unsigned int, CMasterKey> MasterKeyMap; MasterKeyMap mapMasterKeys; @@ -47,15 +47,12 @@ public: pwalletdbEncryption = NULL; } - mutable CCriticalSection cs_mapWallet; std::map<uint256, CWalletTx> mapWallet; std::vector<uint256> vWalletUpdated; std::map<uint256, int> mapRequestCount; - mutable CCriticalSection cs_mapRequestCount; std::map<CBitcoinAddress, std::string> mapAddressBook; - mutable CCriticalSection cs_mapAddressBook; std::vector<unsigned char> vchDefaultKey; @@ -107,7 +104,7 @@ public: { CBitcoinAddress address; if (ExtractAddress(txout.scriptPubKey, this, address)) - CRITICAL_BLOCK(cs_mapAddressBook) + CRITICAL_BLOCK(cs_wallet) if (!mapAddressBook.count(address)) return true; return false; @@ -171,15 +168,13 @@ public: int LoadWallet(bool& fFirstRunRet); // bool BackupWallet(const std::string& strDest); - // requires cs_mapAddressBook lock bool SetAddressBookName(const CBitcoinAddress& address, const std::string& strName); - // requires cs_mapAddressBook lock bool DelAddressBookName(const CBitcoinAddress& address); void UpdatedTransaction(const uint256 &hashTx) { - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) vWalletUpdated.push_back(hashTx); } @@ -187,7 +182,7 @@ public: void Inventory(const uint256 &hash) { - CRITICAL_BLOCK(cs_mapRequestCount) + CRITICAL_BLOCK(cs_wallet) { std::map<uint256, int>::iterator mi = mapRequestCount.find(hash); if (mi != mapRequestCount.end()) |