Add separate lock for SpendingKey key store operations
This commit is contained in:
@@ -86,7 +86,7 @@ bool CBasicKeyStore::HaveWatchOnly() const
|
|||||||
|
|
||||||
bool CBasicKeyStore::AddSpendingKey(const libzcash::SpendingKey &sk)
|
bool CBasicKeyStore::AddSpendingKey(const libzcash::SpendingKey &sk)
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_SpendingKeyStore);
|
||||||
mapSpendingKeys[sk.address()] = sk;
|
mapSpendingKeys[sk.address()] = sk;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class CKeyStore
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
mutable CCriticalSection cs_KeyStore;
|
mutable CCriticalSection cs_KeyStore;
|
||||||
|
mutable CCriticalSection cs_SpendingKeyStore;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~CKeyStore() {}
|
virtual ~CKeyStore() {}
|
||||||
@@ -120,7 +121,7 @@ public:
|
|||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_SpendingKeyStore);
|
||||||
result = (mapSpendingKeys.count(address) > 0);
|
result = (mapSpendingKeys.count(address) > 0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -128,7 +129,7 @@ public:
|
|||||||
bool GetSpendingKey(const libzcash::PaymentAddress &address, libzcash::SpendingKey &skOut) const
|
bool GetSpendingKey(const libzcash::PaymentAddress &address, libzcash::SpendingKey &skOut) const
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_SpendingKeyStore);
|
||||||
SpendingKeyMap::const_iterator mi = mapSpendingKeys.find(address);
|
SpendingKeyMap::const_iterator mi = mapSpendingKeys.find(address);
|
||||||
if (mi != mapSpendingKeys.end())
|
if (mi != mapSpendingKeys.end())
|
||||||
{
|
{
|
||||||
@@ -142,7 +143,7 @@ public:
|
|||||||
{
|
{
|
||||||
setAddress.clear();
|
setAddress.clear();
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_SpendingKeyStore);
|
||||||
SpendingKeyMap::const_iterator mi = mapSpendingKeys.begin();
|
SpendingKeyMap::const_iterator mi = mapSpendingKeys.begin();
|
||||||
while (mi != mapSpendingKeys.end())
|
while (mi != mapSpendingKeys.end())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user