Bitcoin full node and query server

May 22, 2025

View in context in the libbitcoin Slack #general mirror.

evoskuil15:44
The major change to confirmation is the removal of work accumulation in the candidate branch for comparison to the confirmed branch in the case where no blocks in the confirmed branch are to be reorganized, since the comparison in that case is always against zero and all blocks have positive work. This removes database queries that are unnecessary in all typical confirmations (simplified).
void chaser_confirm::do_bumped() NOEXCEPT
{
    size_t fork_point{};
    const auto& query = archive();
    const auto top = query.get_top_confirmed();
    auto fork = query.get_validated_fork(fork_point, checkpoint());

    if (fork_point > top)
    {
        fault(error::confirm1);
        return;
    }

    // ADDED THIS CONDITION...
    if (fork_point < top)
    {
        uint256_t work{};
        if (!query.get_work(work, fork))
        {
            fault(error::confirm2);
            return;
        }

        bool strong{};
        if (!query.get_strong_fork(strong, work, fork_point))
        {
            fault(error::confirm3);
            return;
        }

        if (!strong)
            return;
    }

    reorganize(fork, top, fork_point);
}
(edited)