aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-03-27 20:42:09 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-03-27 20:42:49 +0200
commite49ba2e23b78b33de92fe90d48c60252f2135616 (patch)
tree49fad424d2ca4f104f7a2bc81748bd1f577c4cda /src
parentbf8fc7d352ad7451329a29e5d65e4136a7834a8c (diff)
parentf381299d64784c60cda30be48ea30a6469f05d35 (diff)
downloadbitcoin-e49ba2e23b78b33de92fe90d48c60252f2135616.tar.xz
Merge #12762: Make CKeyStore an interface
f381299 Move CKeyStore::cs_KeyStore to CBasicKeyStore (João Barbosa) 25eb9f5 Inline CKeyStore::AddKey(const CKey &) in CBasicKeyStore (João Barbosa) Pull request description: Made these simplifications while reviewing #12714. This aims to make `CKeyStore` a *pure* interface: - no variable members - the mutex is moved to `CBasicKeyStore` which is where it is used; - no method implementations - `AddKey(const CKey &)` is moved to `CBasicKeyStore` which is where it is needed. Tree-SHA512: 84e44f4390c59600e5cefa599b5464e1771c31dd4abc678ef50db8e06ffac778d692860a352918444f8bcd66430634637b6277a818a658721ffc4f381c1c6a90
Diffstat (limited to 'src')
-rw-r--r--src/keystore.cpp4
-rw-r--r--src/keystore.h7
2 files changed, 3 insertions, 8 deletions
diff --git a/src/keystore.cpp b/src/keystore.cpp
index fab1b81c9a..dfdfa5ea9f 100644
--- a/src/keystore.cpp
+++ b/src/keystore.cpp
@@ -7,10 +7,6 @@
#include <util.h>
-bool CKeyStore::AddKey(const CKey &key) {
- return AddKeyPubKey(key, key.GetPubKey());
-}
-
void CBasicKeyStore::ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey)
{
AssertLockHeld(cs_KeyStore);
diff --git a/src/keystore.h b/src/keystore.h
index ff5613f617..fa912cb195 100644
--- a/src/keystore.h
+++ b/src/keystore.h
@@ -18,13 +18,9 @@
/** A virtual base class for key stores */
class CKeyStore : public SigningProvider
{
-protected:
- mutable CCriticalSection cs_KeyStore;
-
public:
//! Add a key to the store.
virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) =0;
- virtual bool AddKey(const CKey &key);
//! Check whether a key corresponding to a given address is present in the store.
virtual bool HaveKey(const CKeyID &address) const =0;
@@ -51,6 +47,8 @@ typedef std::set<CScript> WatchOnlySet;
class CBasicKeyStore : public CKeyStore
{
protected:
+ mutable CCriticalSection cs_KeyStore;
+
KeyMap mapKeys;
WatchKeyMap mapWatchKeys;
ScriptMap mapScripts;
@@ -60,6 +58,7 @@ protected:
public:
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
+ bool AddKey(const CKey &key) { return AddKeyPubKey(key, key.GetPubKey()); }
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
bool HaveKey(const CKeyID &address) const override;
std::set<CKeyID> GetKeys() const override;