]> Git Repo - VerusCoin.git/commitdiff
obtain cs_wallet mutex to protect vchDefaultKey
authorGavin Andresen <[email protected]>
Thu, 1 Sep 2011 14:58:08 +0000 (10:58 -0400)
committerGavin Andresen <[email protected]>
Thu, 1 Sep 2011 14:58:08 +0000 (10:58 -0400)
src/wallet.cpp

index e861416e5071628afbd6ebcd2d39a2c422c0e885..8bbb80cf254a71b34afcc8c6ca72eaffa9226de8 100644 (file)
@@ -1280,20 +1280,23 @@ bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse)
 {
     int64 nIndex = 0;
     CKeyPool keypool;
-    ReserveKeyFromKeyPool(nIndex, keypool);
-    if (nIndex == -1)
+    CRITICAL_BLOCK(cs_wallet)
     {
-        if (fAllowReuse && !vchDefaultKey.empty())
+        ReserveKeyFromKeyPool(nIndex, keypool);
+        if (nIndex == -1)
         {
-            result = vchDefaultKey;
+            if (fAllowReuse && !vchDefaultKey.empty())
+            {
+                result = vchDefaultKey;
+                return true;
+            }
+            if (IsLocked()) return false;
+            result = GenerateNewKey();
             return true;
         }
-        if (IsLocked()) return false;
-        result = GenerateNewKey();
-        return true;
+        KeepKey(nIndex);
+        result = keypool.vchPubKey;
     }
-    KeepKey(nIndex);
-    result = keypool.vchPubKey;
     return true;
 }
 
This page took 0.031521 seconds and 4 git commands to generate.