SetCrypted() obtains keystore lock, to be safe.
authorGavin Andresen <gavinandresen@gmail.com>
Wed, 31 Aug 2011 18:00:41 +0000 (14:00 -0400)
committerGavin Andresen <gavinandresen@gmail.com>
Wed, 31 Aug 2011 18:00:41 +0000 (14:00 -0400)
src/keystore.cpp
src/keystore.h

index 5bf919c..68f57e7 100644 (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();
index d1e4985..bbfac83 100644 (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);