Skip to content

Commit

Permalink
Merge pull request #899 from AntelopeIO/GH-882-throttle-sync
Browse files Browse the repository at this point in the history
[1.0.3] P2P: Schedule a retry of enqueue_sync_block when throttled
  • Loading branch information
heifner authored Oct 7, 2024
2 parents 5e32912 + 54d46a8 commit 9a1d68b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,12 @@ namespace eosio {
if( current_rate_sec >= block_sync_rate_limit ) {
block_sync_throttling = true;
peer_dlog( this, "throttling block sync to peer ${host}:${port}", ("host", log_remote_endpoint_ip)("port", log_remote_endpoint_port));
std::shared_ptr<boost::asio::steady_timer> throttle_timer = std::make_shared<boost::asio::steady_timer>(my_impl->thread_pool.get_executor());
throttle_timer->expires_from_now(std::chrono::milliseconds(100));
throttle_timer->async_wait(boost::asio::bind_executor(strand, [c=shared_from_this(), throttle_timer](const boost::system::error_code& ec) {
if (!ec)
c->enqueue_sync_block();
}));
return false;
}
}
Expand Down

0 comments on commit 9a1d68b

Please sign in to comment.