From 3c868d2b036f41966fd77e061ede630a3c5d5f5c Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Thu, 12 Jul 2018 15:35:41 -0600 Subject: [PATCH] Consolidate for loops --- src/wallet/wallet.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c936e3934..12516a01b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -891,12 +891,6 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) // height is one below it. nd->witnessHeight = pindex->nHeight - 1; } - } - } - nWitnessCacheSize -= 1; - for (std::pair& wtxItem : mapWallet) { - for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { - SproutNoteData* nd = &(item.second); // Check the validity of the cache // Technically if there are notes witnessed above the current // height, their cache will now be invalid (relative to the new @@ -908,10 +902,13 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) // reindex because the on-disk blocks had already resulted in a // chain that didn't trigger the assertion below. if (nd->witnessHeight < pindex->nHeight) { - assert(nWitnessCacheSize >= nd->witnesses.size()); + // Subtract 1 to compare to what nWitnessCacheSize will be after + // decrementing. + assert((nWitnessCacheSize - 1) >= nd->witnesses.size()); } } } + nWitnessCacheSize -= 1; // TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302) assert(nWitnessCacheSize > 0);