From 7db898efe1c6964bb5a40bbb60b437935f7ffaf9 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Tue, 3 Sep 2024 20:29:24 +0200 Subject: [PATCH] fixme: prevent crash after new block is found This doesn't solve the underlying problem. --- src/sv2/template_provider.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sv2/template_provider.cpp b/src/sv2/template_provider.cpp index df02523d0dd77f..6168f290492999 100644 --- a/src/sv2/template_provider.cpp +++ b/src/sv2/template_provider.cpp @@ -364,6 +364,11 @@ void Sv2TemplateProvider::PruneBlockTemplateCache() // If the blocks prevout is not the tip's prevout, delete it. uint256 prev_hash = m_best_prev_hash; std::erase_if(m_block_template_cache, [prev_hash] (const auto& kv) { + // TODO: this shouldn't happen, but it does. + // Investigate after the mining interface is merged / stable. + // When trying testnet4 mining, using only the pool role, + // the node would crash immediately after finding a block. + if (!kv.second) return true; if (kv.second->getBlockHeader().hashPrevBlock != prev_hash) { return true; }