Browse Source

CKeystore: move relevant implementation out of the header

0.16
Jonas Schnelli 7 years ago
parent
commit
3155fd23f2
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D
  1. 30
      src/keystore.cpp
  2. 34
      src/keystore.h

30
src/keystore.cpp

@ -36,6 +36,36 @@ bool CBasicKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
return true; return true;
} }
bool CBasicKeyStore::HaveKey(const CKeyID &address) const
{
LOCK(cs_KeyStore);
return mapKeys.count(address) > 0;
}
std::set<CKeyID> CBasicKeyStore::GetKeys() const
{
LOCK(cs_KeyStore);
std::set<CKeyID> set_address;
for (const auto& mi : mapKeys) {
set_address.insert(mi.first);
}
return set_address;
}
bool CBasicKeyStore::GetKey(const CKeyID &address, CKey &keyOut) const
{
{
LOCK(cs_KeyStore);
KeyMap::const_iterator mi = mapKeys.find(address);
if (mi != mapKeys.end())
{
keyOut = mi->second;
return true;
}
}
return false;
}
bool CBasicKeyStore::AddCScript(const CScript& redeemScript) bool CBasicKeyStore::AddCScript(const CScript& redeemScript)
{ {
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE) if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)

34
src/keystore.h

@ -62,37 +62,9 @@ protected:
public: public:
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override; bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override; bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
bool HaveKey(const CKeyID &address) const override bool HaveKey(const CKeyID &address) const override;
{ std::set<CKeyID> GetKeys() const override;
bool result; bool GetKey(const CKeyID &address, CKey &keyOut) const override;
{
LOCK(cs_KeyStore);
result = (mapKeys.count(address) > 0);
}
return result;
}
std::set<CKeyID> GetKeys() const override
{
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
{
{
LOCK(cs_KeyStore);
KeyMap::const_iterator mi = mapKeys.find(address);
if (mi != mapKeys.end())
{
keyOut = mi->second;
return true;
}
}
return false;
}
bool AddCScript(const CScript& redeemScript) override; bool AddCScript(const CScript& redeemScript) override;
bool HaveCScript(const CScriptID &hash) const override; bool HaveCScript(const CScriptID &hash) const override;
bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const override; bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const override;

Loading…
Cancel
Save