Skip to content

Commit

Permalink
Merge pull request #715 from evoskuil/master
Browse files Browse the repository at this point in the history
Implement prevout table optionality.
  • Loading branch information
evoskuil authored Jan 23, 2025
2 parents 470a474 + ae9334e commit 74cacb3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/bitcoin/node/chasers/chaser_confirm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 19 additions & 2 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
}

Expand Down Expand Up @@ -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)))
{
Expand All @@ -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);
Expand All @@ -231,14 +246,16 @@ 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;
}
}
else if (ec == database::error::block_confirmable)
{
// Set in either case.
if (!query.set_strong(link))
{
fault(error::confirm6);
Expand Down

0 comments on commit 74cacb3

Please sign in to comment.