Skip to content
Open
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
16 changes: 16 additions & 0 deletions plugins/net_plugin/include/eosio/net_plugin/auto_bp_peering.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class bp_connection_manager {
uint32_t pending_schedule_version = 0;
uint32_t active_schedule_version = 0;

// when leaving bp gossip group, set to false to prevent reconnecting
std::atomic<bool> connect_bp_gossip_peers = true;

fc::mutex mtx;
gossip_buffer_initial_factory initial_gossip_msg_factory GUARDED_BY(mtx);
name_set_t active_bps GUARDED_BY(mtx);
Expand Down Expand Up @@ -256,6 +259,7 @@ class bp_connection_manager {
}
}
} else {
connect_bp_gossip_peers = false;
fc_wlog(p2p_log, "On-chain peer-key not found for configured BP ${a}", ("a", bp_account));
}
}
Expand Down Expand Up @@ -506,6 +510,11 @@ class bp_connection_manager {

// thread-safe
void connect_to_active_bp_peers() {
if (!connect_bp_gossip_peers) {
fc_dlog(p2p_conn_log, "Not in active bp gossip group, not connecting to any bp peers");
return;
}

// do not hold mutexes when calling resolve_and_connect which acquires connections mutex since other threads
// can be holding connections mutex when trying to acquire these mutexes
address_set_t addresses;
Expand Down Expand Up @@ -537,6 +546,10 @@ class bp_connection_manager {

fc_dlog(p2p_conn_log, "pending_connections: ${c}", ("c", to_string(pending_connections)));

if (!pending_connections.empty()) {
connect_bp_gossip_peers = true;
}

// do not hold mutexes when calling resolve_and_connect which acquires connections mutex since other threads
// can be holding connections mutex when trying to acquire these mutexes
address_set_t addresses = find_gossip_bp_addresses(pending_connections, "connect");
Expand Down Expand Up @@ -592,6 +605,9 @@ class bp_connection_manager {
bool disconnect_from_all = !config.my_bp_gossip_accounts.empty() &&
std::all_of(config.my_bp_gossip_accounts.begin(), config.my_bp_gossip_accounts.end(),
[&](const auto& e) { return peers_to_drop.contains(e.first); });
if (disconnect_from_all) {
connect_bp_gossip_peers = false;
}

address_set_t addresses = disconnect_from_all
? all_gossip_bp_addresses("disconnect")
Expand Down
Loading