Compare commits

...

3 Commits

Author SHA1 Message Date
Jon Atack
7a79cd01f4
Merge 724546e28a5778e1c3f5100406ed7237f76aab55 into cd8089c20baaaee329cbf7951195953a9f86d7cf 2025-03-16 17:16:07 +01:00
Jon Atack
724546e28a netinfo: return shortened services, if peers list requested
When the detailed peers list is requested, return the shortened services in the
-netinfo header in the same format as the "serv" column, instead of the full names
list in the report.
2025-02-16 12:12:12 -06:00
Jon Atack
3851960576 netinfo: return local services in the default report 2025-02-16 11:55:05 -06:00

View File

@ -481,6 +481,16 @@ private:
}
return str;
}
std::string ServicesList(const UniValue& services)
{
std::vector<std::string> v;
for (size_t i = 0; i < services.size(); ++i) {
std::string s{ToLower((services[i].get_str()))};
std::ranges::replace(s, '_', ' ');
v.push_back(s);
}
return Join(v, ", ");
}
public:
static constexpr int ID_PEERINFO = 0;
@ -572,7 +582,8 @@ public:
}
// Generate report header.
std::string result{strprintf("%s client %s%s - server %i%s\n\n", CLIENT_NAME, FormatFullVersion(), ChainToString(), networkinfo["protocolversion"].getInt<int>(), networkinfo["subversion"].get_str())};
const std::string_view services{DetailsRequested() ? strprintf(" - services %s", FormatServices(networkinfo["localservicesnames"])) : ""};
std::string result{strprintf("%s client %s%s - server %i%s%s\n\n", CLIENT_NAME, FormatFullVersion(), ChainToString(), networkinfo["protocolversion"].getInt<int>(), networkinfo["subversion"].get_str(), services)};
// Report detailed peer connections list sorted by direction and minimum ping time.
if (DetailsRequested() && !m_peers.empty()) {
@ -654,6 +665,9 @@ public:
}
// Report local addresses, ports, and scores.
if (!DetailsRequested()) {
result += strprintf("\n\nLocal services: %s", ServicesList(networkinfo["localservicesnames"]));
}
result += "\n\nLocal addresses";
const std::vector<UniValue>& local_addrs{networkinfo["localaddresses"].getValues()};
if (local_addrs.empty()) {