Skip to content

Commit f629f10

Browse files
jonatackluke-jr
authored andcommitted
netinfo: return local services in the default report
Credit to l0rinc for refactoring ServicesList(). Co-authored-by: l0rinc <[email protected]> Github-Pull: bitcoin#31886 Rebased-From: fb9b118
1 parent 8cb6ab0 commit f629f10

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/bitcoin-cli.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,17 @@ class NetinfoRequestHandler : public BaseRequestHandler
481481
}
482482
return str;
483483
}
484+
static std::string ServicesList(const UniValue& services)
485+
{
486+
std::string str{services.size() ? services[0].get_str() : ""};
487+
for (size_t i{1}; i < services.size(); ++i) {
488+
str += ", " + services[i].get_str();
489+
}
490+
for (auto& c: str) {
491+
c = (c == '_' ? ' ' : ToLower(c));
492+
}
493+
return str;
494+
}
484495

485496
public:
486497
static constexpr int ID_PEERINFO = 0;
@@ -654,6 +665,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
654665
}
655666

656667
// Report local addresses, ports, and scores.
668+
result += strprintf("\n\nLocal services: %s", ServicesList(networkinfo["localservicesnames"]));
657669
result += "\n\nLocal addresses";
658670
const std::vector<UniValue>& local_addrs{networkinfo["localaddresses"].getValues()};
659671
if (local_addrs.empty()) {

0 commit comments

Comments
 (0)