From 29e65bf536d26abdab1f85fab415e51a25fa758a Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 26 Jan 2023 16:51:23 -0700 Subject: [PATCH] Tolerate missing cached conflict data in ThreadNotifyWallets --- src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 4e1d816dd..cbcaa83c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4132,7 +4132,13 @@ std::pair, std::optional> TakeRecentlyConflict { AssertLockHeld(cs_main); - std::list conflictedTxs = recentlyConflictedTxs.at(pindex); + // We use bracket notation for retrieving conflict data from recentlyConflictedTxs + // here because when a node restarts, the wallet may be behind the node's view of + // the current chain tip. The node may continue reindexing from the chain tip, but + // no entries will exist in `recentlyConflictedTxs` until the next block after the + // node's chain tip at the point of shutdown. In these cases, the wallet cannot learn + // about conflicts in those blocks (which should be fine). + std::list conflictedTxs = recentlyConflictedTxs[pindex]; recentlyConflictedTxs.erase(pindex); if (recentlyConflictedTxs.empty()) { return std::make_pair(conflictedTxs, nConnectedSequence);