Merge pull request #3401
012ca1cLoadWallet: acquire cs_wallet mutex before clearing setKeyPool (Wladimir J. van der Laan)9569168Document cs_wallet lock and add AssertLockHeld (Wladimir J. van der Laan)19a5676Use mutex pointer instead of name for AssertLockHeld (Wladimir J. van der Laan)
This commit is contained in:
13
src/wallet.h
13
src/wallet.h
@@ -105,6 +105,11 @@ private:
|
||||
int64_t nLastResend;
|
||||
|
||||
public:
|
||||
/// Main wallet lock.
|
||||
/// This lock protects all the fields added by CWallet
|
||||
/// except for:
|
||||
/// fFileBacked (immutable after instantiation)
|
||||
/// strWalletFile (immutable after instantiation)
|
||||
mutable CCriticalSection cs_wallet;
|
||||
|
||||
bool fFileBacked;
|
||||
@@ -154,10 +159,11 @@ public:
|
||||
int64_t nTimeFirstKey;
|
||||
|
||||
// check whether we are allowed to upgrade (or already support) to the named feature
|
||||
bool CanSupportFeature(enum WalletFeature wf) { return nWalletMaxVersion >= wf; }
|
||||
bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; }
|
||||
|
||||
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL) const;
|
||||
bool SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
|
||||
|
||||
bool IsLockedCoin(uint256 hash, unsigned int n) const;
|
||||
void LockCoin(COutPoint& output);
|
||||
void UnlockCoin(COutPoint& output);
|
||||
@@ -174,7 +180,7 @@ public:
|
||||
// Load metadata (used by LoadWallet)
|
||||
bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata);
|
||||
|
||||
bool LoadMinVersion(int nVersion) { nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
|
||||
bool LoadMinVersion(int nVersion) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
|
||||
|
||||
// Adds an encrypted key to the store, and saves it to disk.
|
||||
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
|
||||
@@ -323,6 +329,7 @@ public:
|
||||
|
||||
unsigned int GetKeyPoolSize()
|
||||
{
|
||||
AssertLockHeld(cs_wallet); // setKeyPool
|
||||
return setKeyPool.size();
|
||||
}
|
||||
|
||||
@@ -335,7 +342,7 @@ public:
|
||||
bool SetMaxVersion(int nVersion);
|
||||
|
||||
// get the current wallet format (the oldest client version guaranteed to understand this wallet)
|
||||
int GetVersion() { return nWalletVersion; }
|
||||
int GetVersion() { AssertLockHeld(cs_wallet); return nWalletVersion; }
|
||||
|
||||
/** Address book entry changed.
|
||||
* @note called with lock cs_wallet held.
|
||||
|
||||
Reference in New Issue
Block a user