# HG changeset patch # User Gavin Andresen # Date 1314813641 14400 # Node ID 03e517c58ffe52dcdefb12c904a9efc0152e8635 # Parent c275abdf08c32aa6c2d788c366fab33afc3baae9 SetCrypted() obtains keystore lock, to be safe. diff --git a/src/keystore.cpp b/src/keystore.cpp --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -33,6 +33,19 @@ return true; } +bool CCryptoKeyStore::SetCrypted() +{ + CRITICAL_BLOCK(cs_KeyStore) + { + if (fUseCrypto) + return true; + if (!mapKeys.empty()) + return false; + fUseCrypto = true; + } + return true; +} + std::vector CCryptoKeyStore::GenerateNewKey() { RandAddSeedPerfmon(); diff --git a/src/keystore.h b/src/keystore.h --- a/src/keystore.h +++ b/src/keystore.h @@ -65,15 +65,7 @@ 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);