diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-08-16 10:56:55 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-08-16 10:56:55 +0100 |
commit | 42b34b35450ca73585ccbd7c13143f2b3cbf1b70 (patch) | |
tree | 91f58591885f429dc098fed36be2a86a75538db2 | |
parent | Merge pull request #2286 (diff) | |
download | monero-42b34b35450ca73585ccbd7c13143f2b3cbf1b70.tar.xz |
Consistently print peer id in hex and on 16 chars
Diffstat (limited to '')
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 2 | ||||
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 5b3b059a4..4dd93bf6e 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -203,7 +203,7 @@ namespace cryptonote } std::stringstream peer_id_str; - peer_id_str << std::hex << peer_id; + peer_id_str << std::hex << std::setw(16) << peer_id; peer_id_str >> cnx.peer_id; cnx.support_flags = support_flags; diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 995fee484..bd2142ab1 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -55,7 +55,9 @@ namespace { std::string port_str; std::string elapsed = epee::misc_utils::get_time_interval_string(now - last_seen); std::string ip_str = epee::string_tools::get_ip_string_from_int32(peer.ip); - epee::string_tools::xtype_to_string(peer.id, id_str); + std::stringstream peer_id_str; + peer_id_str << std::hex << std::setw(16) << peer.id; + peer_id_str >> id_str; epee::string_tools::xtype_to_string(peer.port, port_str); std::string addr_str = ip_str + ":" + port_str; tools::msg_writer() << boost::format("%-10s %-25s %-25s %s") % prefix % id_str % addr_str % elapsed; @@ -112,10 +114,15 @@ namespace { return base + " -- " + status; } - std::string pad(std::string s, size_t n) + std::string pad(std::string s, size_t n, char c = ' ', bool prepend = false) { if (s.size() < n) - s.append(n - s.size(), ' '); + { + if (prepend) + s = std::string(n - s.size(), c) + s; + else + s.append(n - s.size(), c); + } return s; } } @@ -490,7 +497,7 @@ bool t_rpc_command_executor::print_connections() { tools::msg_writer() //<< std::setw(30) << std::left << in_out << std::setw(30) << std::left << address - << std::setw(20) << info.peer_id + << std::setw(20) << pad(info.peer_id, 16, '0', true) << std::setw(20) << info.support_flags << std::setw(30) << std::to_string(info.recv_count) + "(" + std::to_string(info.recv_idle_time) + ")/" + std::to_string(info.send_count) + "(" + std::to_string(info.send_idle_time) + ")" << std::setw(25) << info.state @@ -1742,7 +1749,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.height << " " << p.info.current_download << " kB/s, " << nblocks << " blocks / " << size/1e6 << " MB queued"; + tools::success_msg_writer() << address << " " << pad(p.info.peer_id, 16, '0', true) << " " << p.info.height << " " << p.info.current_download << " kB/s, " << nblocks << " blocks / " << size/1e6 << " MB queued"; } uint64_t total_size = 0; |