mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Consolidate service flag bit-to-name conversion to a shared serviceFlagToStr function
Side effect: this results in the RPC showing unknown service bits as "UNKNOWN[n]" like the GUI. Note that there is no common mask-to-vector<string> function because both GUI and RPC would need to iterate through it to convert to their desired target formats.
This commit is contained in:
parent
cea91a1e40
commit
c31bc5bcfd
4 changed files with 35 additions and 30 deletions
|
|
@ -736,18 +736,15 @@ std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, Fl
|
|||
|
||||
UniValue GetServicesNames(ServiceFlags services)
|
||||
{
|
||||
const uint64_t services_n = services;
|
||||
UniValue servicesNames(UniValue::VARR);
|
||||
|
||||
if (services & NODE_NETWORK)
|
||||
servicesNames.push_back("NETWORK");
|
||||
if (services & NODE_GETUTXO)
|
||||
servicesNames.push_back("GETUTXO");
|
||||
if (services & NODE_BLOOM)
|
||||
servicesNames.push_back("BLOOM");
|
||||
if (services & NODE_WITNESS)
|
||||
servicesNames.push_back("WITNESS");
|
||||
if (services & NODE_NETWORK_LIMITED)
|
||||
servicesNames.push_back("NETWORK_LIMITED");
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
const uint64_t mask = 1ull << i;
|
||||
if (services_n & mask) {
|
||||
servicesNames.push_back(serviceFlagToStr(mask, i));
|
||||
}
|
||||
}
|
||||
|
||||
return servicesNames;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue