Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/bitcoin/node/chasers/chaser_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class BCN_API chaser_validate

// These are protected by strand.
header_links batched_{};
header_links invalids_{};
network::threadpool validation_threadpool_;

// These are thread safe.
Expand Down
12 changes: 9 additions & 3 deletions src/chasers/chaser_validate_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ bool chaser_validate::is_maximum() NOEXCEPT
// Invalids might not be included in batched, as link push is a race.
// Collected links are only required to set valid, not invalid, and do not
// need to coincide with the batch that is currently being processed (!).
// A batched_ value may not be present in the current batched_ set despite
// being invalid here, which is expected. However upon invalidation and failure
// to match here, this block id will subsequently land in batched_ and would
// then be reported as valid, overriding the unconfirmable block state set
// below, so invalids_ are cached for process lifetime.
bool chaser_validate::process_invalids(const header_links& invalids) NOEXCEPT
{
BC_ASSERT(stranded());
Expand All @@ -182,15 +187,16 @@ bool chaser_validate::process_invalids(const header_links& invalids) NOEXCEPT
!query.set_block_unconfirmable(link))
return false;

invalids_.push_back(link);
notify_block(system::error::invalid_signature, height, link, false);
}

// Set all invalids links in batched_ to terminal (to be skipped).
if (!invalids.empty())
// Set all invalid links in batched_ to terminal (to be skipped).
if (!invalids_.empty())
{
std::ranges::replace_if(batched_, [&](const auto& link) NOEXCEPT
{
return contains(invalids, link);
return contains(invalids_, link);
}, header_link::terminal);
}

Expand Down
Loading