From 25eb9f50205b8e391cabbbf721711e08169c3773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Fri, 23 Mar 2018 00:57:09 +0000 Subject: [PATCH 1/2] Inline CKeyStore::AddKey(const CKey &) in CBasicKeyStore --- src/keystore.cpp | 4 ---- src/keystore.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/keystore.cpp b/src/keystore.cpp index fab1b81c9..dfdfa5ea9 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -7,10 +7,6 @@ #include -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 ffd3238fd..2cca42c45 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -25,7 +25,6 @@ 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; @@ -64,6 +63,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 GetKeys() const override; From f381299d64784c60cda30be48ea30a6469f05d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Fri, 23 Mar 2018 00:57:33 +0000 Subject: [PATCH 2/2] Move CKeyStore::cs_KeyStore to CBasicKeyStore --- doc/developer-notes.md | 2 +- src/keystore.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 8f06ee4ec..ecc993674 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -218,7 +218,7 @@ inconsistencies reported in the debug.log file. 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 index 2cca42c45..38d02fb36 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -17,9 +17,6 @@ /** A virtual base class for key stores */ class CKeyStore { -protected: - mutable CCriticalSection cs_KeyStore; - public: virtual ~CKeyStore() {} @@ -54,6 +51,8 @@ typedef std::set WatchOnlySet; class CBasicKeyStore : public CKeyStore { protected: + mutable CCriticalSection cs_KeyStore; + KeyMap mapKeys; WatchKeyMap mapWatchKeys; ScriptMap mapScripts;