From ae9334ea1266ab6eb423e7f54afc58bb5e29f46e Mon Sep 17 00:00:00 2001 From: evoskuil Date: Wed, 22 Jan 2025 19:29:51 -0500 Subject: [PATCH] Implement prevout table optionality. --- .../bitcoin/node/chasers/chaser_confirm.hpp | 1 + src/chasers/chaser_confirm.cpp | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/bitcoin/node/chasers/chaser_confirm.hpp b/include/bitcoin/node/chasers/chaser_confirm.hpp index ebd504f4..f6ecbf5b 100644 --- a/include/bitcoin/node/chasers/chaser_confirm.hpp +++ b/include/bitcoin/node/chasers/chaser_confirm.hpp @@ -91,6 +91,7 @@ class BCN_API chaser_confirm // These are thread safe. network::asio::strand independent_strand_; const bool concurrent_; + bool prevout_; }; } // namespace node diff --git a/src/chasers/chaser_confirm.cpp b/src/chasers/chaser_confirm.cpp index 83a88995..1afca87f 100644 --- a/src/chasers/chaser_confirm.cpp +++ b/src/chasers/chaser_confirm.cpp @@ -43,7 +43,8 @@ chaser_confirm::chaser_confirm(full_node& node) NOEXCEPT : chaser(node), threadpool_(one, node.config().node.priority_()), independent_strand_(threadpool_.service().get_executor()), - concurrent_(node.config().node.concurrent_confirmation) + concurrent_(node.config().node.concurrent_confirmation), + prevout_(node.archive().prevout_enabled()) { } @@ -204,6 +205,13 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT } else if (ec == database::error::block_valid) { + // Set before if not using prevout table. + if (!prevout_ && !query.set_strong(link)) + { + fault(error::confirm5); + return; + } + // Confirmation query. if ((ec = query.block_confirmable(link))) { @@ -213,6 +221,13 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT return; } + // Unset from set before if not using prevout table. + if (!prevout_ && !query.set_unstrong(link)) + { + fault(error::confirm5); + return; + } + if (!query.set_block_unconfirmable(link)) { fault(error::confirm3); @@ -231,7 +246,8 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT return; } - if (!query.set_strong(link)) + // Set after if using prevout table. + if (prevout_ && !query.set_strong(link)) { fault(error::confirm5); return; @@ -239,6 +255,7 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT } else if (ec == database::error::block_confirmable) { + // Set in either case. if (!query.set_strong(link)) { fault(error::confirm6);