diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-09 13:25:17 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-09 13:25:17 -0700 |
commit | 1a275bac2b5454ae9d6744f28c29cbf40e2fbf13 (patch) | |
tree | 4cf7a1b4001ef82c15f4942f6a495aaf530c7d0e /src/keystore.h | |
parent | 1044391135b9d2e309c1e960afc72afa2a7e04f5 (diff) | |
parent | f342dac1cb06d5b0d264fa59e448ef6477ec5b6b (diff) |
Merge pull request #1052 from sipa/scopedlocks
Use scoped locks instead of CRITICAL_BLOCK
Diffstat (limited to 'src/keystore.h')
-rw-r--r-- | src/keystore.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/keystore.h b/src/keystore.h index c32db2620a..282eaaa047 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -54,15 +54,17 @@ public: bool HaveKey(const CBitcoinAddress &address) const { bool result; - CRITICAL_BLOCK(cs_KeyStore) + { + LOCK(cs_KeyStore); result = (mapKeys.count(address) > 0); + } return result; } void GetKeys(std::set<CBitcoinAddress> &setAddress) const { setAddress.clear(); - CRITICAL_BLOCK(cs_KeyStore) { + LOCK(cs_KeyStore); KeyMap::const_iterator mi = mapKeys.begin(); while (mi != mapKeys.end()) { @@ -73,8 +75,8 @@ public: } bool GetKey(const CBitcoinAddress &address, CKey &keyOut) const { - CRITICAL_BLOCK(cs_KeyStore) { + LOCK(cs_KeyStore); KeyMap::const_iterator mi = mapKeys.find(address); if (mi != mapKeys.end()) { @@ -129,8 +131,10 @@ public: if (!IsCrypted()) return false; bool result; - CRITICAL_BLOCK(cs_KeyStore) + { + LOCK(cs_KeyStore); result = vMasterKey.empty(); + } return result; } @@ -139,8 +143,10 @@ public: if (!SetCrypted()) return false; - CRITICAL_BLOCK(cs_KeyStore) + { + LOCK(cs_KeyStore); vMasterKey.clear(); + } return true; } @@ -149,8 +155,8 @@ public: bool AddKey(const CKey& key); bool HaveKey(const CBitcoinAddress &address) const { - CRITICAL_BLOCK(cs_KeyStore) { + LOCK(cs_KeyStore); if (!IsCrypted()) return CBasicKeyStore::HaveKey(address); return mapCryptedKeys.count(address) > 0; |