SetCrypted() obtains keystore lock, to be safe.

This commit is contained in:
Gavin Andresen 2011-08-31 14:00:41 -04:00
parent 541e585d8e
commit e3c26b2573
2 changed files with 14 additions and 9 deletions

View File

@ -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();

View File

@ -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);