From e3c26b2573c75850827558daf5f04594c1360296 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 31 Aug 2011 14:00:41 -0400 Subject: [PATCH] SetCrypted() obtains keystore lock, to be safe. --- src/keystore.cpp | 13 +++++++++++++ src/keystore.h | 10 +--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/keystore.cpp b/src/keystore.cpp index 5bf919c..68f57e7 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -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 CCryptoKeyStore::GenerateNewKey() { RandAddSeedPerfmon(); diff --git a/src/keystore.h b/src/keystore.h index d1e4985..bbfac83 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -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); -- 1.7.1