From 3fac1020e70e83b1f731aee20b2ad286a8553b53 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 31 Aug 2016 02:09:17 +1200 Subject: [PATCH] Remove GetNoteDecryptors(), lock inside FindMyNotes() instead --- src/keystore.h | 15 +-------------- src/wallet/gtest/test_wallet.cpp | 7 ------- src/wallet/wallet.cpp | 5 ++--- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/keystore.h b/src/keystore.h index 478c06cb8..aa3aefdf2 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -145,7 +145,7 @@ public: bool GetNoteDecryptor(const libzcash::PaymentAddress &address, ZCNoteDecryption &decOut) const { { - LOCK(cs_KeyStore); + LOCK(cs_SpendingKeyStore); NoteDecryptorMap::const_iterator mi = mapNoteDecryptors.find(address); if (mi != mapNoteDecryptors.end()) { @@ -155,19 +155,6 @@ public: } return false; } - void GetNoteDecryptors(std::set &setDec) const - { - setDec.clear(); - { - LOCK(cs_SpendingKeyStore); - NoteDecryptorMap::const_iterator mi = mapNoteDecryptors.begin(); - while (mi != mapNoteDecryptors.end()) - { - setDec.insert(*mi); - mi++; - } - } - } void GetPaymentAddresses(std::set &setAddress) const { setAddress.clear(); diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index bd15b73d4..02c3362e0 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -16,13 +16,6 @@ using ::testing::Return; ZCJoinSplit* params = ZCJoinSplit::Unopened(); -class MockCCoinsViewCache : public CCoinsViewCache { -public: - MockCCoinsViewCache() : CCoinsViewCache(NULL) { }; - - MOCK_CONST_METHOD2(GetAnchorAt, bool(const uint256 &rt, ZCIncrementalMerkleTree &tree)); -}; - class TestWallet : public CWallet { public: TestWallet() : CWallet() { } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 227697862..dd229310b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1030,16 +1030,15 @@ void CWallet::EraseFromWallet(const uint256 &hash) mapNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const { + LOCK(cs_SpendingKeyStore); uint256 hash = tx.GetTxid(); mapNoteData_t noteData; - std::set decryptors; - GetNoteDecryptors(decryptors); libzcash::SpendingKey key; for (size_t i = 0; i < tx.vjoinsplit.size(); i++) { auto hSig = tx.vjoinsplit[i].h_sig(*pzcashParams, tx.joinSplitPubKey); for (uint8_t j = 0; j < tx.vjoinsplit[i].ciphertexts.size(); j++) { - for (const NoteDecryptorMap::value_type& item : decryptors) { + for (const NoteDecryptorMap::value_type& item : mapNoteDecryptors) { try { auto note_pt = libzcash::NotePlaintext::decrypt( item.second,