From 6e263a5fd3a6933d0525f07c8991368dc43e0fde Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 16 Oct 2016 16:26:51 -0500 Subject: [PATCH] Address review comments --- src/wallet/rpcwallet.cpp | 1 + src/wallet/wallet.cpp | 11 +++++++---- src/wallet/wallet.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7775fc771..4d6608570 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1877,6 +1877,7 @@ Value walletpassphrase(const Array& params, bool fHelp) "walletpassphrase \n" "Stores the wallet decryption key in memory for seconds."); + // No need to check return values, because the wallet was unlocked above pwalletMain->UpdateNullifierNoteMap(); pwalletMain->TopUpKeyPool(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 70c87dad5..5e98e8dc2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -890,13 +890,16 @@ bool CWallet::UpdateNullifierNoteMap() item.first.n); } } - UpdateNullifierNoteMap(wtxItem.second); + UpdateNullifierNoteMapWithTx(wtxItem.second); } } return true; } -void CWallet::UpdateNullifierNoteMap(const CWalletTx& wtx) +/** + * Update mapNullifiersToNotes with the cached nullifiers in this tx. + */ +void CWallet::UpdateNullifierNoteMapWithTx(const CWalletTx& wtx) { { LOCK(cs_wallet); @@ -916,7 +919,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD { mapWallet[hash] = wtxIn; mapWallet[hash].BindWallet(this); - UpdateNullifierNoteMap(mapWallet[hash]); + UpdateNullifierNoteMapWithTx(mapWallet[hash]); AddToSpends(hash); } else @@ -926,7 +929,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD pair::iterator, bool> ret = mapWallet.insert(make_pair(hash, wtxIn)); CWalletTx& wtx = (*ret.first).second; wtx.BindWallet(this); - UpdateNullifierNoteMap(wtx); + UpdateNullifierNoteMapWithTx(wtx); bool fInsertedNew = ret.second; if (fInsertedNew) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index fafad6d12..42d985045 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -868,7 +868,7 @@ public: void MarkDirty(); bool UpdateNullifierNoteMap(); - void UpdateNullifierNoteMap(const CWalletTx& wtx); + void UpdateNullifierNoteMapWithTx(const CWalletTx& wtx); bool AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb); void SyncTransaction(const CTransaction& tx, const CBlock* pblock); bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate);