]> Git Repo - VerusCoin.git/commitdiff
Don't delete transactions from wallet in range loop
authormiketout <[email protected]>
Fri, 20 Dec 2019 23:40:54 +0000 (15:40 -0800)
committermiketout <[email protected]>
Fri, 20 Dec 2019 23:40:54 +0000 (15:40 -0800)
src/wallet/wallet.cpp

index 263a1afda8ea2088e534ea540c18c3b956c38617..60fbe08af9271e37126c1c20fdc09ff2a56576ae 100644 (file)
@@ -2439,6 +2439,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                                         deleteSpentFrom = idMapKey.blockHeight;
                                     }
 
+                                    std::vector<uint256> txesToErase;
+
                                     for (auto &txidAndWtx : mapWallet)
                                     {
                                         txidAndWtx.second.MarkDirty();
@@ -2511,7 +2513,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                                         }
                                         if (eraseTx)
                                         {
-                                            EraseFromWallet(txidAndWtx.first);
+                                            txesToErase.push_back(txidAndWtx.first);
 
                                             for (auto &checkID : oneTxIDs)
                                             {
@@ -2520,6 +2522,11 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                                         }
                                     }
 
+                                    for (auto hash : txesToErase)
+                                    {
+                                        EraseFromWallet(hash);
+                                    }
+
                                     // now, we've deleted all transactions that were only in the wallet due to our ability to sign with the ID just removed
                                     // loop through all transactions and remove all IDs found in the remaining transactions from our idsToCheck set after we 
                                     // have gone through all wallet transactions, we can delete all IDs remaining in the idsToCheck set
This page took 0.027779 seconds and 4 git commands to generate.