From 580c057ec69f2620fa9b8dfc5b242656a686e623 Mon Sep 17 00:00:00 2001 From: maogo Date: Tue, 22 Aug 2023 04:15:21 +0800 Subject: [PATCH] sync_info format peer list format peer list --- src/daemon/rpc_command_executor.cpp | 41 ++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index fbf26db85..21139df83 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -2274,14 +2274,35 @@ bool t_rpc_command_executor::sync_info() uint64_t target = res.target_height < res.height ? res.height : res.target_height; tools::success_msg_writer() << "Height: " << res.height << ", target: " << target << " (" << (100.0 * res.height / target) << "%)"; uint64_t current_download = 0; + uint32_t longest_host_width = 15; for (const auto &p: res.peers) + { current_download += p.info.current_download; + if(p.info.address.length() > longest_host_width) + { + longest_host_width = p.info.address.length(); + } + } + longest_host_width += 8; tools::success_msg_writer() << "Downloading at " << current_download << " kB/s"; if (res.next_needed_pruning_seed) tools::success_msg_writer() << "Next needed pruning seed: " << res.next_needed_pruning_seed; tools::success_msg_writer() << std::to_string(res.peers.size()) << " peers"; - tools::success_msg_writer() << "Remote Host Peer_ID State Prune_Seed Height DL kB/s, Queued Blocks / MB"; + std::string table_line = "+" + std::string(longest_host_width - 1,'-')+ "+" + std::string(20 - 1,'-') + "+" + std::string(20 - 1,'-') + "+" + std::string(15 - 1,'-') + "+" + std::string(15 - 1,'-') + "+" + std::string(15 - 1,'-') + "+" + std::string(15 - 1,'-') + "+" + std::string(15 - 1,'-') + "+"; + tools::success_msg_writer() + < 0) tools::success_msg_writer() << res.overview; for (const auto &s: res.spans) {