From 2ec15a693165db96dd7e75ee060ea4622a47ab7a Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 12 Aug 2017 10:59:54 +0100 Subject: [PATCH] daemon: print peers' top height in sync_info --- src/cryptonote_protocol/cryptonote_protocol_defs.h | 3 +++ src/cryptonote_protocol/cryptonote_protocol_handler.inl | 5 ++++- src/daemon/rpc_command_executor.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_protocol/cryptonote_protocol_defs.h b/src/cryptonote_protocol/cryptonote_protocol_defs.h index 37b503436..6e6c83f04 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_defs.h +++ b/src/cryptonote_protocol/cryptonote_protocol_defs.h @@ -76,6 +76,8 @@ namespace cryptonote boost::uuids::uuid connection_id; + uint64_t height; + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(incoming) KV_SERIALIZE(localhost) @@ -97,6 +99,7 @@ namespace cryptonote KV_SERIALIZE(current_upload) KV_SERIALIZE(support_flags) KV_SERIALIZE_VAL_POD_AS_BLOB(connection_id) + KV_SERIALIZE(height) END_KV_SERIALIZE_MAP() }; diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index f9fe6fe70..b5a307208 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -239,6 +239,8 @@ namespace cryptonote cnx.connection_id = cntxt.m_connection_id; + cnx.height = cntxt.m_remote_blockchain_height; + connections.push_back(cnx); return true; @@ -264,6 +266,8 @@ namespace cryptonote return false; } + context.m_remote_blockchain_height = hshd.current_height; + uint64_t target = m_core.get_target_blockchain_height(); if (target == 0) target = m_core.get_current_blockchain_height(); @@ -293,7 +297,6 @@ namespace cryptonote } LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id); context.m_state = cryptonote_connection_context::state_synchronizing; - context.m_remote_blockchain_height = hshd.current_height; //let the socket to send response to handshake, but request callback, to let send request data after response LOG_PRINT_CCONTEXT_L2("requesting callback"); ++context.m_callback_request_count; diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 34d87d282..995fee484 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -1742,7 +1742,7 @@ bool t_rpc_command_executor::sync_info() for (const auto &s: res.spans) if (s.rate > 0.0f && s.connection_id == p.info.connection_id) nblocks += s.nblocks, size += s.size; - tools::success_msg_writer() << address << " " << p.info.peer_id << " " << p.info.current_download << " kB/s, " << nblocks << " blocks / " << size/1e6 << " MB queued"; + tools::success_msg_writer() << address << " " << p.info.peer_id << " " << p.info.height << " " << p.info.current_download << " kB/s, " << nblocks << " blocks / " << size/1e6 << " MB queued"; } uint64_t total_size = 0;