Skip to content

Commit e49ba2e

Browse files
committed
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
2 parents bf8fc7d + f381299 commit e49ba2e

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

doc/developer-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ inconsistencies reported in the debug.log file.
219219

220220
Re-architecting the core code so there are better-defined interfaces
221221
between the various components is a goal, with any necessary locking
222-
done by the components (e.g. see the self-contained CKeyStore class
222+
done by the components (e.g. see the self-contained CBasicKeyStore class
223223
and its cs_KeyStore lock for example).
224224

225225
Threads

src/keystore.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77

88
#include <util.h>
99

10-
bool CKeyStore::AddKey(const CKey &key) {
11-
return AddKeyPubKey(key, key.GetPubKey());
12-
}
13-
1410
void CBasicKeyStore::ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey)
1511
{
1612
AssertLockHeld(cs_KeyStore);

src/keystore.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@
1818
/** A virtual base class for key stores */
1919
class CKeyStore : public SigningProvider
2020
{
21-
protected:
22-
mutable CCriticalSection cs_KeyStore;
23-
2421
public:
2522
//! Add a key to the store.
2623
virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) =0;
27-
virtual bool AddKey(const CKey &key);
2824

2925
//! Check whether a key corresponding to a given address is present in the store.
3026
virtual bool HaveKey(const CKeyID &address) const =0;
@@ -51,6 +47,8 @@ typedef std::set<CScript> WatchOnlySet;
5147
class CBasicKeyStore : public CKeyStore
5248
{
5349
protected:
50+
mutable CCriticalSection cs_KeyStore;
51+
5452
KeyMap mapKeys;
5553
WatchKeyMap mapWatchKeys;
5654
ScriptMap mapScripts;
@@ -60,6 +58,7 @@ class CBasicKeyStore : public CKeyStore
6058

6159
public:
6260
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
61+
bool AddKey(const CKey &key) { return AddKeyPubKey(key, key.GetPubKey()); }
6362
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
6463
bool HaveKey(const CKeyID &address) const override;
6564
std::set<CKeyID> GetKeys() const override;

0 commit comments

Comments
 (0)