diff --git a/doc/developer-notes.md b/doc/developer-notes.md --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -280,7 +280,7 @@ Re-architecting the core code so there are better-defined interfaces between the various components is a goal, with any necessary locking -done by the components (e.g. see the self-contained CKeyStore class +done by the components (e.g. see the self-contained CBasicKeyStore class and its cs_KeyStore lock for example). Threads diff --git a/src/keystore.h b/src/keystore.h --- a/src/keystore.h +++ b/src/keystore.h @@ -16,15 +16,11 @@ /** A virtual base class for key stores */ class CKeyStore { -protected: - mutable CCriticalSection cs_KeyStore; - public: virtual ~CKeyStore() {} //! 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. @@ -57,6 +53,8 @@ /** Basic key store, that keeps keys in an address->secret map */ class CBasicKeyStore : public CKeyStore { protected: + mutable CCriticalSection cs_KeyStore; + KeyMap mapKeys; WatchKeyMap mapWatchKeys; ScriptMap mapScripts; @@ -66,6 +64,7 @@ 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 GetKeys() const override; diff --git a/src/keystore.cpp b/src/keystore.cpp --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -9,10 +9,6 @@ #include #include -bool CKeyStore::AddKey(const CKey &key) { - return AddKeyPubKey(key, key.GetPubKey()); -} - void CBasicKeyStore::ImplicitlyLearnRelatedKeyScripts(const CPubKey &pubkey) { AssertLockHeld(cs_KeyStore); CKeyID key_id = pubkey.GetID();