aboutsummaryrefslogtreecommitdiff
path: root/src/keystore.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-09-07 22:03:41 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-09-07 22:04:18 +0200
commite6ab88a4524a6dce40b985655a03a3607d4f38b7 (patch)
tree6ec48cf7f486c0f533584561017dd296541965f5 /src/keystore.h
parent2f0d3e604aa934d71bfc88e69fa8e03a571042a3 (diff)
parentfe09b0197c20dc3c0a614c1a94dac708ef206743 (diff)
Merge #10916: add missing lock to crypter GetKeys()
fe09b0197 add missing lock to crypter GetKeys() (Marko Bencun) 5cb3da04b keystore GetKeys(): return result instead of writing to reference (Marko Bencun) Pull request description: Issue: #10905 First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines. Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
Diffstat (limited to 'src/keystore.h')
-rw-r--r--src/keystore.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/keystore.h b/src/keystore.h
index 528b6e0834..9b85ddb0ec 100644
--- a/src/keystore.h
+++ b/src/keystore.h
@@ -30,7 +30,7 @@ public:
//! Check whether a key corresponding to a given address is present in the store.
virtual bool HaveKey(const CKeyID &address) const =0;
virtual bool GetKey(const CKeyID &address, CKey& keyOut) const =0;
- virtual void GetKeys(std::set<CKeyID> &setAddress) const =0;
+ virtual std::set<CKeyID> GetKeys() const =0;
virtual bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const =0;
//! Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki
@@ -71,18 +71,14 @@ public:
}
return result;
}
- void GetKeys(std::set<CKeyID> &setAddress) const override
+ std::set<CKeyID> GetKeys() const override
{
- setAddress.clear();
- {
- LOCK(cs_KeyStore);
- KeyMap::const_iterator mi = mapKeys.begin();
- while (mi != mapKeys.end())
- {
- setAddress.insert((*mi).first);
- mi++;
- }
+ LOCK(cs_KeyStore);
+ std::set<CKeyID> set_address;
+ for (const auto& mi : mapKeys) {
+ set_address.insert(mi.first);
}
+ return set_address;
}
bool GetKey(const CKeyID &address, CKey &keyOut) const override
{