From 38bc62741b82cca179fb8e3437a388b0e0f67842 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Fri, 7 Nov 2025 13:20:57 -0600 Subject: [PATCH] Blockchain: cancel pop_blocks() operation on interupt On SIGINT, `Blockchain::cancel()` is called, which sets `m_cancel` to `true`. This commit stops attempting to pop blocks from the chain once that flag is set. This should leave the blockchain in a well-define state, even if the `pop_blocks()` operation itself did not "complete". --- src/cryptonote_core/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 171087dae..ce330f39b 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -562,7 +562,7 @@ void Blockchain::pop_blocks(uint64_t nblocks) const uint64_t blockchain_height = m_db->height(); if (blockchain_height > 0) nblocks = std::min(nblocks, blockchain_height - 1); - while (i < nblocks) + while (i < nblocks && !m_cancel.load()) { pop_block_from_blockchain(); ++i;