From faa46475d7d7dc60dcc80be34826cf98fb25dc95 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 7 Feb 2019 14:46:08 -0500 Subject: wallet: Add lock annotation for mapAddressBook --- src/wallet/rpcdump.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.cpp | 5 ++--- src/wallet/wallet.h | 14 +++++++------- src/wallet/wallettool.cpp | 1 - 5 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src/wallet') diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 32c36ceaeb..6fd0e60d57 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -66,7 +66,7 @@ static std::string DecodeDumpString(const std::string &str) { return ret.str(); } -static bool GetWalletAddressesForKey(CWallet * const pwallet, const CKeyID &keyid, std::string &strAddr, std::string &strLabel) +static bool GetWalletAddressesForKey(CWallet* const pwallet, const CKeyID& keyid, std::string& strAddr, std::string& strLabel) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { bool fLabelFound = false; CKey key; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e38ad3a0ba..b9d993dc9c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1309,7 +1309,7 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest) * @param filter_ismine The "is mine" filter flags. * @param filter_label Optional label string to filter incoming transactions. */ -static void ListTransactions(interfaces::Chain::Lock& locked_chain, CWallet* const pwallet, const CWalletTx& wtx, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter_ismine, const std::string* filter_label) +static void ListTransactions(interfaces::Chain::Lock& locked_chain, CWallet* const pwallet, const CWalletTx& wtx, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter_ismine, const std::string* filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { CAmount nFee; std::list listReceived; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index bdddcd718b..af93653375 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3172,7 +3172,7 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s { bool fUpdated = false; { - LOCK(cs_wallet); // mapAddressBook + LOCK(cs_wallet); std::map::iterator mi = mapAddressBook.find(address); fUpdated = mi != mapAddressBook.end(); mapAddressBook[address].name = strName; @@ -3189,7 +3189,7 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s bool CWallet::DelAddressBook(const CTxDestination& address) { { - LOCK(cs_wallet); // mapAddressBook + LOCK(cs_wallet); // Delete destdata tuples associated with address std::string strAddress = EncodeDestination(address); @@ -3869,7 +3869,6 @@ bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, st std::vector CWallet::GetDestValues(const std::string& prefix) const { - LOCK(cs_wallet); std::vector values; for (const auto& address : mapAddressBook) { for (const auto& data : address.second.destdata) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index cf3fa0aced..9dde7e1f94 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -788,7 +788,7 @@ public: int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0; uint64_t nAccountingEntryNumber = 0; - std::map mapAddressBook; + std::map mapAddressBook GUARDED_BY(cs_wallet); std::set setLockedCoins GUARDED_BY(cs_wallet); @@ -865,15 +865,15 @@ public: bool LoadCScript(const CScript& redeemScript); //! Adds a destination data tuple to the store, and saves it to disk - bool AddDestData(const CTxDestination &dest, const std::string &key, const std::string &value); + bool AddDestData(const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! Erases a destination data tuple in the store and on disk - bool EraseDestData(const CTxDestination &dest, const std::string &key); + bool EraseDestData(const CTxDestination& dest, const std::string& key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! Adds a destination data tuple to the store, without saving it to disk - void LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value); + void LoadDestData(const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! Look up a destination data tuple in the store, return true if found false otherwise - bool GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const; + bool GetDestData(const CTxDestination& dest, const std::string& key, std::string* value) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! Get all destination values matching a prefix. - std::vector GetDestValues(const std::string& prefix) const; + std::vector GetDestValues(const std::string& prefix) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! Adds a watch-only address to the store, and saves it to disk. bool AddWatchOnly(const CScript& dest, int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); @@ -1041,7 +1041,7 @@ public: bool DelAddressBook(const CTxDestination& address); - const std::string& GetLabelName(const CScript& scriptPubKey) const; + const std::string& GetLabelName(const CScript& scriptPubKey) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void GetScriptForMining(std::shared_ptr &script); diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp index 30b0c48eef..628f3fe803 100644 --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -94,7 +94,6 @@ static std::shared_ptr LoadWallet(const std::string& name, const fs::pa static void WalletShowInfo(CWallet* wallet_instance) { - // lock required because of some AssertLockHeld() LOCK(wallet_instance->cs_wallet); fprintf(stdout, "Wallet info\n===========\n"); -- cgit v1.2.3