Remove GetNoteDecryptors(), lock inside FindMyNotes() instead

This commit is contained in:
Jack Grigg 2016-08-31 02:09:17 +12:00
parent de42390f90
commit 3fac1020e7
3 changed files with 3 additions and 24 deletions

View File

@ -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<NoteDecryptorMap::value_type> &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<libzcash::PaymentAddress> &setAddress) const
{
setAddress.clear();

View File

@ -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() { }

View File

@ -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<NoteDecryptorMap::value_type> 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,