mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 11:23:26 +01:00
print peer id in 0 padded hex for consistency
This commit is contained in:
parent
8f8cc09ba1
commit
5524bc3151
@ -314,6 +314,18 @@ POP_WARNINGS
|
||||
return str;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string pad_string(std::string s, size_t n, char c = ' ', bool prepend = false)
|
||||
{
|
||||
if (s.size() < n)
|
||||
{
|
||||
if (prepend)
|
||||
s = std::string(n - s.size(), c) + s;
|
||||
else
|
||||
s.append(n - s.size(), c);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
template<class t_pod_type>
|
||||
std::string pod_to_hex(const t_pod_type& s)
|
||||
{
|
||||
|
@ -113,18 +113,6 @@ namespace {
|
||||
return base;
|
||||
return base + " -- " + status;
|
||||
}
|
||||
|
||||
std::string pad(std::string s, size_t n, char c = ' ', bool prepend = false)
|
||||
{
|
||||
if (s.size() < n)
|
||||
{
|
||||
if (prepend)
|
||||
s = std::string(n - s.size(), c) + s;
|
||||
else
|
||||
s.append(n - s.size(), c);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
t_rpc_command_executor::t_rpc_command_executor(
|
||||
@ -497,7 +485,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) << pad(info.peer_id, 16, '0', true)
|
||||
<< std::setw(20) << epee::string_tools::pad_string(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
|
||||
@ -1744,12 +1732,12 @@ bool t_rpc_command_executor::sync_info()
|
||||
tools::success_msg_writer() << std::to_string(res.peers.size()) << " peers";
|
||||
for (const auto &p: res.peers)
|
||||
{
|
||||
std::string address = pad(p.info.address, 24);
|
||||
std::string address = epee::string_tools::pad_string(p.info.address, 24);
|
||||
uint64_t nblocks = 0, size = 0;
|
||||
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 << " " << pad(p.info.peer_id, 16, '0', true) << " " << p.info.height << " " << p.info.current_download << " kB/s, " << nblocks << " blocks / " << size/1e6 << " MB queued";
|
||||
tools::success_msg_writer() << address << " " << epee::string_tools::pad_string(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;
|
||||
@ -1758,7 +1746,7 @@ bool t_rpc_command_executor::sync_info()
|
||||
tools::success_msg_writer() << std::to_string(res.spans.size()) << " spans, " << total_size/1e6 << " MB";
|
||||
for (const auto &s: res.spans)
|
||||
{
|
||||
std::string address = pad(s.remote_address, 24);
|
||||
std::string address = epee::string_tools::pad_string(s.remote_address, 24);
|
||||
if (s.size == 0)
|
||||
{
|
||||
tools::success_msg_writer() << address << " " << s.nblocks << " (" << s.start_block_height << " - " << (s.start_block_height + s.nblocks - 1) << ") -";
|
||||
|
@ -1077,7 +1077,7 @@ namespace nodetool
|
||||
bool node_server<t_payload_net_handler>::make_new_connection_from_anchor_peerlist(const std::vector<anchor_peerlist_entry>& anchor_peerlist)
|
||||
{
|
||||
for (const auto& pe: anchor_peerlist) {
|
||||
_note("Considering connecting (out) to peer: " << pe.id << " " << pe.adr.str());
|
||||
_note("Considering connecting (out) to peer: " << peerid_type(pe.id) << " " << pe.adr.str());
|
||||
|
||||
if(is_peer_used(pe)) {
|
||||
_note("Peer is used");
|
||||
@ -1092,7 +1092,7 @@ namespace nodetool
|
||||
continue;
|
||||
}
|
||||
|
||||
MDEBUG("Selected peer: " << pe.id << " " << pe.adr.str()
|
||||
MDEBUG("Selected peer: " << peerid_to_string(pe.id) << " " << pe.adr.str()
|
||||
<< "[peer_type=" << anchor
|
||||
<< "] first_seen: " << epee::misc_utils::get_time_interval_string(time(NULL) - pe.first_seen));
|
||||
|
||||
@ -1145,7 +1145,7 @@ namespace nodetool
|
||||
|
||||
++try_count;
|
||||
|
||||
_note("Considering connecting (out) to peer: " << pe.id << " " << pe.adr.str());
|
||||
_note("Considering connecting (out) to peer: " << peerid_to_string(pe.id) << " " << pe.adr.str());
|
||||
|
||||
if(is_peer_used(pe)) {
|
||||
_note("Peer is used");
|
||||
@ -1158,7 +1158,7 @@ namespace nodetool
|
||||
if(is_addr_recently_failed(pe.adr))
|
||||
continue;
|
||||
|
||||
MDEBUG("Selected peer: " << pe.id << " " << pe.adr.str()
|
||||
MDEBUG("Selected peer: " << peerid_to_string(pe.id) << " " << pe.adr.str()
|
||||
<< "[peer_list=" << (use_white_list ? white : gray)
|
||||
<< "] last_seen: " << (pe.last_seen ? epee::misc_utils::get_time_interval_string(time(NULL) - pe.last_seen) : "never"));
|
||||
|
||||
@ -1962,14 +1962,14 @@ namespace nodetool
|
||||
if (!success) {
|
||||
m_peerlist.remove_from_peer_gray(pe);
|
||||
|
||||
LOG_PRINT_L2("PEER EVICTED FROM GRAY PEER LIST IP address: " << pe.adr.host_str() << " Peer ID: " << std::hex << pe.id);
|
||||
LOG_PRINT_L2("PEER EVICTED FROM GRAY PEER LIST IP address: " << pe.adr.host_str() << " Peer ID: " << peerid_type(pe.id));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
m_peerlist.set_peer_just_seen(pe.id, pe.adr);
|
||||
|
||||
LOG_PRINT_L2("PEER PROMOTED TO WHITE PEER LIST IP address: " << pe.adr.host_str() << " Peer ID: " << std::hex << pe.id);
|
||||
LOG_PRINT_L2("PEER PROMOTED TO WHITE PEER LIST IP address: " << pe.adr.host_str() << " Peer ID: " << peerid_type(pe.id));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -44,6 +44,13 @@ namespace nodetool
|
||||
typedef boost::uuids::uuid uuid;
|
||||
typedef uint64_t peerid_type;
|
||||
|
||||
static inline std::string peerid_to_string(peerid_type peer_id)
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << std::hex << peer_id;
|
||||
return epee::string_tools::pad_string(s.str(), 16, '0', true);
|
||||
}
|
||||
|
||||
#pragma pack (push, 1)
|
||||
|
||||
struct network_address_old
|
||||
|
Loading…
Reference in New Issue
Block a user