Browse Source

Rename mapNullifiersToNotes to mapSproutNullifiersToNotes.

pull/4/head
Simon 6 years ago
parent
commit
f41bf503e1
  1. 20
      src/wallet/gtest/test_wallet.cpp
  2. 14
      src/wallet/wallet.cpp
  3. 2
      src/wallet/wallet.h

20
src/wallet/gtest/test_wallet.cpp

@ -524,13 +524,13 @@ TEST(wallet_tests, navigate_from_nullifier_to_note) {
wtx.SetSproutNoteData(noteData);
EXPECT_EQ(0, wallet.mapNullifiersToNotes.count(nullifier));
EXPECT_EQ(0, wallet.mapSproutNullifiersToNotes.count(nullifier));
wallet.AddToWallet(wtx, true, NULL);
EXPECT_EQ(1, wallet.mapNullifiersToNotes.count(nullifier));
EXPECT_EQ(wtx.GetHash(), wallet.mapNullifiersToNotes[nullifier].hash);
EXPECT_EQ(0, wallet.mapNullifiersToNotes[nullifier].js);
EXPECT_EQ(1, wallet.mapNullifiersToNotes[nullifier].n);
EXPECT_EQ(1, wallet.mapSproutNullifiersToNotes.count(nullifier));
EXPECT_EQ(wtx.GetHash(), wallet.mapSproutNullifiersToNotes[nullifier].hash);
EXPECT_EQ(0, wallet.mapSproutNullifiersToNotes[nullifier].js);
EXPECT_EQ(1, wallet.mapSproutNullifiersToNotes[nullifier].n);
}
TEST(wallet_tests, spent_note_is_from_me) {
@ -1046,17 +1046,17 @@ TEST(wallet_tests, UpdateNullifierNoteMap) {
wtx.SetSproutNoteData(noteData);
wallet.AddToWallet(wtx, true, NULL);
EXPECT_EQ(0, wallet.mapNullifiersToNotes.count(nullifier));
EXPECT_EQ(0, wallet.mapSproutNullifiersToNotes.count(nullifier));
EXPECT_FALSE(wallet.UpdateNullifierNoteMap());
ASSERT_TRUE(wallet.Unlock(vMasterKey));
EXPECT_TRUE(wallet.UpdateNullifierNoteMap());
EXPECT_EQ(1, wallet.mapNullifiersToNotes.count(nullifier));
EXPECT_EQ(wtx.GetHash(), wallet.mapNullifiersToNotes[nullifier].hash);
EXPECT_EQ(0, wallet.mapNullifiersToNotes[nullifier].js);
EXPECT_EQ(1, wallet.mapNullifiersToNotes[nullifier].n);
EXPECT_EQ(1, wallet.mapSproutNullifiersToNotes.count(nullifier));
EXPECT_EQ(wtx.GetHash(), wallet.mapSproutNullifiersToNotes[nullifier].hash);
EXPECT_EQ(0, wallet.mapSproutNullifiersToNotes[nullifier].js);
EXPECT_EQ(1, wallet.mapSproutNullifiersToNotes[nullifier].n);
}
TEST(wallet_tests, UpdatedNoteData) {

14
src/wallet/wallet.cpp

@ -1164,7 +1164,7 @@ bool CWallet::UpdateNullifierNoteMap()
}
/**
* Update mapNullifiersToNotes with the cached nullifiers in this tx.
* Update mapSproutNullifiersToNotes with the cached nullifiers in this tx.
*/
void CWallet::UpdateNullifierNoteMapWithTx(const CWalletTx& wtx)
{
@ -1172,7 +1172,7 @@ void CWallet::UpdateNullifierNoteMapWithTx(const CWalletTx& wtx)
LOCK(cs_wallet);
for (const mapSproutNoteData_t::value_type& item : wtx.mapSproutNoteData) {
if (item.second.nullifier) {
mapNullifiersToNotes[*item.second.nullifier] = item.first;
mapSproutNullifiersToNotes[*item.second.nullifier] = item.first;
}
}
}
@ -1378,9 +1378,9 @@ void CWallet::MarkAffectedTransactionsDirty(const CTransaction& tx)
}
for (const JSDescription& jsdesc : tx.vjoinsplit) {
for (const uint256& nullifier : jsdesc.nullifiers) {
if (mapNullifiersToNotes.count(nullifier) &&
mapWallet.count(mapNullifiersToNotes[nullifier].hash)) {
mapWallet[mapNullifiersToNotes[nullifier].hash].MarkDirty();
if (mapSproutNullifiersToNotes.count(nullifier) &&
mapWallet.count(mapSproutNullifiersToNotes[nullifier].hash)) {
mapWallet[mapSproutNullifiersToNotes[nullifier].hash].MarkDirty();
}
}
}
@ -1478,8 +1478,8 @@ bool CWallet::IsFromMe(const uint256& nullifier) const
{
{
LOCK(cs_wallet);
if (mapNullifiersToNotes.count(nullifier) &&
mapWallet.count(mapNullifiersToNotes.at(nullifier).hash)) {
if (mapSproutNullifiersToNotes.count(nullifier) &&
mapWallet.count(mapSproutNullifiersToNotes.at(nullifier).hash)) {
return true;
}
}

2
src/wallet/wallet.h

@ -895,7 +895,7 @@ public:
* - Restarting the node with -reindex (which operates on a locked wallet
* but with the now-cached nullifiers).
*/
std::map<uint256, JSOutPoint> mapNullifiersToNotes;
std::map<uint256, JSOutPoint> mapSproutNullifiersToNotes;
std::map<uint256, CWalletTx> mapWallet;

Loading…
Cancel
Save