Skip to content

Commit

Permalink
GH-1091 Always broadcast blocks we produce
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jan 13, 2025
1 parent 5c0e192 commit 121fadc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class bp_connection_manager {
config.my_bp_accounts.insert(accounts.begin(), accounts.end());
}

// thread safe, my_bp_accounts only modified during plugin startup
bool is_producer(account_name account) const {
return config.my_bp_accounts.count(account) != 0;
}

// Only called at plugin startup
void set_bp_peers(const std::vector<std::string>& peers) {
try {
Expand Down
16 changes: 9 additions & 7 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2757,13 +2757,15 @@ namespace eosio {

if (cp->protocol_version >= proto_block_nack) {
if (cp->consecutive_blocks_nacks > connection::consecutive_block_nacks_threshold) {
auto send_buffer = block_id_buff_factory.get_send_buffer( block_notice_message{id} );
boost::asio::post(cp->strand, [cp, send_buffer{std::move(send_buffer)}, bnum]() {
cp->latest_blk_time = std::chrono::steady_clock::now();
peer_dlog( cp, "bcast block_notice ${b}", ("b", bnum) );
cp->enqueue_buffer( msg_type_t::block_notice_message, false, send_buffer, 0, no_reason );
});
return;
if (!my_impl->is_producer(b->producer)) { // always broadcast our produced blocks
auto send_buffer = block_id_buff_factory.get_send_buffer( block_notice_message{id} );
boost::asio::post(cp->strand, [cp, send_buffer{std::move(send_buffer)}, bnum]() {
cp->latest_blk_time = std::chrono::steady_clock::now();
peer_dlog( cp, "bcast block_notice ${b}", ("b", bnum) );
cp->enqueue_buffer( msg_type_t::block_notice_message, false, send_buffer, 0, no_reason );
});
return;
}
}
}

Expand Down

0 comments on commit 121fadc

Please sign in to comment.