From b83de7f28e71f0b10a999327395198fbcb02f44b Mon Sep 17 00:00:00 2001 From: stickies-v Date: Tue, 3 Mar 2026 15:17:00 +0800 Subject: [PATCH] validation: remove sentinel block from ConnectTrace The sentinel pattern was necessary to collect conflicted transactions before their associated block was recorded, but that tracking was removed in 5613f9842b4000fed088b8cf7b99674c328d15e1. --- src/validation.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 67130a31cfd..b462b7f0144 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2990,39 +2990,24 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra struct PerBlockConnectTrace { CBlockIndex* pindex = nullptr; std::shared_ptr pblock; - PerBlockConnectTrace() = default; }; /** * Used to track blocks whose transactions were applied to the UTXO state as a * part of a single ActivateBestChainStep call. - * - * This class is single-use, once you call GetBlocksConnected() you have to throw - * it away and make a new one. */ class ConnectTrace { private: std::vector blocksConnected; public: - explicit ConnectTrace() : blocksConnected(1) {} - void BlockConnected(CBlockIndex* pindex, std::shared_ptr pblock) { - assert(!blocksConnected.back().pindex); assert(pindex); assert(pblock); - blocksConnected.back().pindex = pindex; - blocksConnected.back().pblock = std::move(pblock); - blocksConnected.emplace_back(); + blocksConnected.emplace_back(pindex, std::move(pblock)); } - std::vector& GetBlocksConnected() { - // We always keep one extra block at the end of our list because - // blocks are added after all the conflicted transactions have - // been filled in. Thus, the last entry should always be an empty - // one waiting for the transactions from the next block. We pop - // the last entry here to make sure the list we return is sane. - assert(!blocksConnected.back().pindex); - blocksConnected.pop_back(); + const std::vector& GetBlocksConnected() const + { return blocksConnected; } };