Mercurial > hg > bitcoin
changeset 896:03e517c58ffe draft
SetCrypted() obtains keystore lock, to be safe.
author | Gavin Andresen <gavinandresen@gmail.com> |
---|---|
date | Wed, 31 Aug 2011 14:00:41 -0400 |
parents | c275abdf08c3 |
children | ec253d7d2ef7 |
files | src/keystore.cpp src/keystore.h |
diffstat | 2 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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<unsigned char> CCryptoKeyStore::GenerateNewKey() { RandAddSeedPerfmon();
--- 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);