Skip to content

Commit

Permalink
Merge pull request #585 from evoskuil/master
Browse files Browse the repository at this point in the history
Remove stopped check in block_in protocol event handler, style.
  • Loading branch information
evoskuil authored Apr 15, 2024
2 parents ea04dc3 + a5ed2e3 commit 0c1d4ad
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
7 changes: 7 additions & 0 deletions include/bitcoin/node/impl/chasers/chaser_organize.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
const auto ec = query.get_header_state(id);
if (ec == database::error::block_unconfirmable)
{
// This eventually stops the peer, but the full set of headers may
// still cycle through to become strong, despite this being stored
// as block_unconfirmable from a block validate or confirm failure.
// Block preconfirmation will then fail and this cycle will
// continue until a strong candidate chain is located. The cycle
// occurs because peers continue to send the same headers,which
// may indicate an local failure or peer failures.
handler(ec, height);
return;
}
Expand Down
1 change: 0 additions & 1 deletion src/chasers/chaser_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ code chaser_check::start() NOEXCEPT
void chaser_check::handle_event(const code&, chase event_,
event_link value) NOEXCEPT
{
using namespace system;
switch (event_)
{
case chase::header:
Expand Down
15 changes: 6 additions & 9 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void chaser_confirm::handle_event(const code&, chase event_,
event_link value) NOEXCEPT
{
// These can come out of order, advance in order synchronously.
using namespace system;
switch (event_)
{
case chase::block:
Expand Down Expand Up @@ -108,7 +107,6 @@ void chaser_confirm::handle_event(const code&, chase event_,
void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
{
BC_ASSERT(stranded());
auto& query = archive();

if (closed())
return;
Expand Down Expand Up @@ -136,8 +134,9 @@ void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
// Reorganize confirmed chain.
// ........................................................................

const auto fork_point = height - fork.size();
auto& query = archive();
const auto top = query.get_top_confirmed();
const auto fork_point = height - fork.size();
if (top < fork_point)
{
fault(error::store_integrity);
Expand All @@ -149,16 +148,14 @@ void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
header_links popped{};
while (index > fork_point)
{
const auto link = query.to_confirmed(index);
popped.push_back(link);

if (!query.pop_confirmed() || link.is_terminal())
popped.push_back(query.to_confirmed(index));
if (popped.back().is_terminal() || !query.pop_confirmed())
{
fault(error::store_integrity);
return;
}

notify(error::success, chase::reorganized, link);
notify(error::success, chase::reorganized, popped.back());
fire(events::block_reorganized, index--);
}

Expand Down Expand Up @@ -301,7 +298,7 @@ bool chaser_confirm::roll_back(const header_links& popped,
if (!set_unconfirmed(query.to_candidate(height), height))
return false;

for (const auto& link : views_reverse(popped))
for (const auto& link: views_reverse(popped))
if (!set_confirmed(link, ++fork_point))
return false;

Expand Down
1 change: 0 additions & 1 deletion src/chasers/chaser_preconfirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void chaser_preconfirm::handle_event(const code&, chase event_,
{
// These come out of order, advance in order asynchronously.
// Asynchronous completion results in out of order notification.
using namespace system;
switch (event_)
{
case chase::start:
Expand Down
4 changes: 0 additions & 4 deletions src/protocols/protocol_block_in_31800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ bool protocol_block_in_31800::is_idle() const NOEXCEPT
void protocol_block_in_31800::handle_event(const code&,
chase event_, event_link value) NOEXCEPT
{
using namespace system;
if (stopped())
return;

switch (event_)
{
case chase::pause:
Expand Down

0 comments on commit 0c1d4ad

Please sign in to comment.