aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-08-31 14:00:41 -0400
committerGavin Andresen <gavinandresen@gmail.com>2011-08-31 14:00:41 -0400
commite3c26b2573c75850827558daf5f04594c1360296 (patch)
treeb59c3e5d7ec1ab9d874bb3a7a8c3fe90b266cd4d
parent541e585d8eeb9b9c981589d2f8c47208f9d4e072 (diff)
downloadbitcoin-e3c26b2573c75850827558daf5f04594c1360296.tar.xz
SetCrypted() obtains keystore lock, to be safe.
-rw-r--r--src/keystore.cpp13
-rw-r--r--src/keystore.h10
2 files changed, 14 insertions, 9 deletions
diff --git a/src/keystore.cpp b/src/keystore.cpp
index 5bf919cb80..68f57e7e0e 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<unsigned char> CCryptoKeyStore::GenerateNewKey()
{
RandAddSeedPerfmon();
diff --git a/src/keystore.h b/src/keystore.h
index d1e4985d5d..bbfac83d1f 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);