Remove GetNoteDecryptors(), lock inside FindMyNotes() instead
This commit is contained in:
parent
de42390f90
commit
3fac1020e7
|
@ -145,7 +145,7 @@ public:
|
||||||
bool GetNoteDecryptor(const libzcash::PaymentAddress &address, ZCNoteDecryption &decOut) const
|
bool GetNoteDecryptor(const libzcash::PaymentAddress &address, ZCNoteDecryption &decOut) const
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_SpendingKeyStore);
|
||||||
NoteDecryptorMap::const_iterator mi = mapNoteDecryptors.find(address);
|
NoteDecryptorMap::const_iterator mi = mapNoteDecryptors.find(address);
|
||||||
if (mi != mapNoteDecryptors.end())
|
if (mi != mapNoteDecryptors.end())
|
||||||
{
|
{
|
||||||
|
@ -155,19 +155,6 @@ public:
|
||||||
}
|
}
|
||||||
return false;
|
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
|
void GetPaymentAddresses(std::set<libzcash::PaymentAddress> &setAddress) const
|
||||||
{
|
{
|
||||||
setAddress.clear();
|
setAddress.clear();
|
||||||
|
|
|
@ -16,13 +16,6 @@ using ::testing::Return;
|
||||||
|
|
||||||
ZCJoinSplit* params = ZCJoinSplit::Unopened();
|
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 {
|
class TestWallet : public CWallet {
|
||||||
public:
|
public:
|
||||||
TestWallet() : CWallet() { }
|
TestWallet() : CWallet() { }
|
||||||
|
|
|
@ -1030,16 +1030,15 @@ void CWallet::EraseFromWallet(const uint256 &hash)
|
||||||
|
|
||||||
mapNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const
|
mapNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
|
LOCK(cs_SpendingKeyStore);
|
||||||
uint256 hash = tx.GetTxid();
|
uint256 hash = tx.GetTxid();
|
||||||
|
|
||||||
mapNoteData_t noteData;
|
mapNoteData_t noteData;
|
||||||
std::set<NoteDecryptorMap::value_type> decryptors;
|
|
||||||
GetNoteDecryptors(decryptors);
|
|
||||||
libzcash::SpendingKey key;
|
libzcash::SpendingKey key;
|
||||||
for (size_t i = 0; i < tx.vjoinsplit.size(); i++) {
|
for (size_t i = 0; i < tx.vjoinsplit.size(); i++) {
|
||||||
auto hSig = tx.vjoinsplit[i].h_sig(*pzcashParams, tx.joinSplitPubKey);
|
auto hSig = tx.vjoinsplit[i].h_sig(*pzcashParams, tx.joinSplitPubKey);
|
||||||
for (uint8_t j = 0; j < tx.vjoinsplit[i].ciphertexts.size(); j++) {
|
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 {
|
try {
|
||||||
auto note_pt = libzcash::NotePlaintext::decrypt(
|
auto note_pt = libzcash::NotePlaintext::decrypt(
|
||||||
item.second,
|
item.second,
|
||||||
|
|
Loading…
Reference in New Issue