netinfo: return local services in the default report

Credit to l0rinc for refactoring ServicesList().

Co-authored-by: l0rinc <pap.lorinc@gmail.com>
Co-authored-by: Daniela Brozzoni <danielabrozzoni@protonmail.com>
This commit is contained in:
Jon Atack
2025-02-16 11:25:43 -06:00
parent d1b583181d
commit 4489ab526a

View File

@@ -463,6 +463,17 @@ private:
}
return str;
}
static std::string ServicesList(const UniValue& services)
{
std::string str{services.size() ? services[0].get_str() : ""};
for (size_t i{1}; i < services.size(); ++i) {
str += ", " + services[i].get_str();
}
for (auto& c: str) {
c = (c == '_' ? ' ' : ToLower(c));
}
return str;
}
public:
static constexpr int ID_PEERINFO = 0;
@@ -636,7 +647,8 @@ public:
}
}
// Report local addresses, ports, and scores.
// Report local services, addresses, ports, and scores.
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()) {