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.
This commit is contained in:
Jon Atack 2025-02-16 09:22:46 -06:00
parent 3851960576
commit 724546e28a

View file

@ -582,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()) {
@ -664,7 +665,9 @@ public:
}
// Report local addresses, ports, and scores.
result += strprintf("\n\nLocal services: %s", ServicesList(networkinfo["localservicesnames"]));
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()) {