Skip to content

Commit

Permalink
GH-1871 Make sure a unique_conn_node_id is always provided to prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Nov 8, 2023
1 parent 42034e3 commit 11df124
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4765,9 +4765,18 @@ namespace eosio {
++num_peers;
}
fc::unique_lock g_conn(c->conn_mtx);
if (c->unique_conn_node_id.empty()) { // still connecting, use temp id so that non-connected peers are reported
if (!c->p2p_address.empty()) {
c->unique_conn_node_id = fc::sha256::hash(c->p2p_address).str().substr(0, 7);
} else if (!c->remote_endpoint_ip.empty()) {
c->unique_conn_node_id = fc::sha256::hash(c->remote_endpoint_ip).str().substr(0, 7);
} else {
c->unique_conn_node_id = fc::sha256::hash(std::to_string(c->connection_id)).str().substr(0, 7);
}
}
std::string conn_node_id = c->unique_conn_node_id;
boost::asio::ip::address_v6::bytes_type addr = c->remote_endpoint_ip_array;
std::string p2p_addr = c->p2p_address;
std::string conn_node_id = c->unique_conn_node_id;
g_conn.unlock();
per_connection.peers.emplace_back(
net_plugin::p2p_per_connection_metrics::connection_metric{
Expand Down

0 comments on commit 11df124

Please sign in to comment.