Browse Source

SetCrypted() obtains keystore lock, to be safe.

miguelfreitas
Gavin Andresen 13 years ago
parent
commit
e3c26b2573
  1. 13
      src/keystore.cpp
  2. 10
      src/keystore.h

13
src/keystore.cpp

@ -33,6 +33,19 @@ bool CBasicKeyStore::AddKey(const CKey& key) @@ -33,6 +33,19 @@ bool CBasicKeyStore::AddKey(const CKey& key)
return true;
}
bool CCryptoKeyStore::SetCrypted()
{
CRITICAL_BLOCK(cs_KeyStore)
{
if (fUseCrypto)
return true;
if (!mapKeys.empty())
return false;
fUseCrypto = true;
}
return true;
}
std::vector<unsigned char> CCryptoKeyStore::GenerateNewKey()
{
RandAddSeedPerfmon();

10
src/keystore.h

@ -65,15 +65,7 @@ private: @@ -65,15 +65,7 @@ private:
bool fUseCrypto;
protected:
bool SetCrypted()
{
if (fUseCrypto)
return true;
if (!mapKeys.empty())
return false;
fUseCrypto = true;
return true;
}
bool SetCrypted();
// will encrypt previously unencrypted keys
bool EncryptKeys(CKeyingMaterial& vMasterKeyIn);

Loading…
Cancel
Save