Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2P: Add last_vote_received to connection status #504

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace eosio {
bool is_socket_open = false;
bool is_blocks_only = false;
bool is_transactions_only = false;
time_point last_vote_received;
handshake_message last_handshake;
};

Expand Down Expand Up @@ -99,4 +100,6 @@ namespace eosio {

}

FC_REFLECT( eosio::connection_status, (peer)(remote_ip)(remote_port)(connecting)(syncing)(is_bp_peer)(is_socket_open)(is_blocks_only)(is_transactions_only)(last_handshake) )
FC_REFLECT( eosio::connection_status, (peer)(remote_ip)(remote_port)(connecting)(syncing)
(is_bp_peer)(is_socket_open)(is_blocks_only)(is_transactions_only)
(last_vote_received)(last_handshake) )
6 changes: 6 additions & 0 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ namespace eosio {
std::atomic<uint16_t> consecutive_immediate_connection_close = 0;
std::atomic<bool> is_bp_connection = false;
block_status_monitor block_status_monitor_;
std::atomic<time_point> last_vote_received;

alignas(hardware_destructive_interference_sz)
fc::mutex sync_response_expected_timer_mtx;
Expand Down Expand Up @@ -1373,6 +1374,9 @@ namespace eosio {
stat.syncing = peer_syncing_from_us;
stat.is_bp_peer = is_bp_connection;
stat.is_socket_open = socket_is_open();
stat.is_blocks_only = is_blocks_only_connection();
stat.is_transactions_only = is_transactions_only_connection();
stat.last_vote_received = last_vote_received;
fc::lock_guard g( conn_mtx );
stat.peer = peer_addr;
stat.remote_ip = log_remote_endpoint_ip;
Expand Down Expand Up @@ -1481,6 +1485,7 @@ namespace eosio {
block_sync_send_start = 0ns;
block_sync_frame_bytes_sent = 0;
block_sync_throttling = false;
last_vote_received = time_point{};

if( reconnect && !shutdown ) {
my_impl->connections.start_conn_timer( std::chrono::milliseconds( 100 ),
Expand Down Expand Up @@ -3680,6 +3685,7 @@ namespace eosio {
}

void connection::handle_message( const vote_message_ptr& msg ) {
last_vote_received = fc::time_point::now();
if (vote_logger.is_enabled(fc::log_level::debug)) {
peer_dlog(this, "received vote: block #${bn}:${id}.., ${v}, key ${k}..",
("bn", block_header::num_from_id(msg->block_id))("id", msg->block_id.str().substr(8,16))
Expand Down