From 8a7b973f8129788576431b75d732511adf951ab4 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 4 Apr 2024 11:23:20 -0500 Subject: [PATCH] GH-2102 Check for terminate_at_block during apply of fork db blocks --- libraries/chain/controller.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 94beaefda3..be0b82fd08 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -4007,6 +4007,12 @@ struct controller_impl { br = controller::block_report{}; apply_block( br, *ritr, valid ? controller::block_status::validated : controller::block_status::complete, trx_lookup ); + + if( conf.terminate_at_block > 0 && conf.terminate_at_block <= chain_head.block_num()) { + ilog("Reached configured maximum block ${num}; terminating", ("num", conf.terminate_at_block) ); + shutdown(); + return; + } } catch ( const std::bad_alloc& ) { throw; } catch ( const boost::interprocess::bad_alloc& ) {