Skip to content

Commit

Permalink
Merge pull request #572 from evoskuil/master
Browse files Browse the repository at this point in the history
Optimize tail end of catch-up downloads with stall message.
  • Loading branch information
evoskuil authored Mar 15, 2024
2 parents c307c84 + 6bc1616 commit ee5920c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion include/bitcoin/node/chasers/chaser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ class BCN_API chaser
/// Issued by 'block_in_31800' and handled by 'session_outbound'.
starved,

/// Channel is directed to split its work and stop (channel_t).
/// Channel (slow) is directed to split its work and stop (channel_t).
/// Issued by 'session_outbound' and handled by 'block_in_31800'.
split,

/// Channels (all with work) are directed to split work and stop (0).
/// Issued by 'session_outbound' and handled by 'block_in_31800'.
stall,

/// A block has been downloaded, checked and stored (height_t).
/// Issued by 'block_in_31800' and handled by 'connect'.
checked,
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/impl/chasers/chaser_organize.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
else
{
// Delay so headers can get current before block download starts.
// Checking currency before notify also avoids excessive work backlog.
if (is_current(header.timestamp()))
notify(error::success, chase::header, point);
}
Expand Down
1 change: 0 additions & 1 deletion src/chasers/chaser_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ bool chaser_header::is_storable(const system::chain::header& header,
state.cumulative_work() >= settings().minimum_work);
}


} // namespace database
} // namespace libbitcoin

Expand Down
9 changes: 9 additions & 0 deletions src/protocols/protocol_block_in_31800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ void protocol_block_in_31800::handle_event(const code&,
POST(do_split, channel);
}
}

// If this channel has work, split it and stop.
else if (event_ == chaser::chase::stall)
{
if (!map_->empty())
{
POST(do_split, chaser::count_t{});
}
}
}

void protocol_block_in_31800::do_get_downloads(chaser::count_t) NOEXCEPT
Expand Down
4 changes: 4 additions & 0 deletions src/sessions/session_outbound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ void session_outbound::split(chaser::channel_t) NOEXCEPT
const auto channel = slowest->first;
speeds_.erase(slowest);
node::session::notify(error::success, chaser::chase::split, channel);
return;
}

// With no speeds recorded there may still be channels with work.
node::session::notify(error::success, chaser::chase::stall, {});
}

// performance
Expand Down

0 comments on commit ee5920c

Please sign in to comment.