mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
util: dedup code in callers of serviceFlagToStr()
Introduce `serviceFlagsToStr()` which hides the internals of the bitmask and simplifies callers of `serviceFlagToStr()`.
This commit is contained in:
@@ -841,14 +841,10 @@ std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, Fl
|
||||
|
||||
UniValue GetServicesNames(ServiceFlags services)
|
||||
{
|
||||
const uint64_t services_n = services;
|
||||
UniValue servicesNames(UniValue::VARR);
|
||||
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
const uint64_t mask = 1ull << i;
|
||||
if (services_n & mask) {
|
||||
servicesNames.push_back(serviceFlagToStr(i));
|
||||
}
|
||||
for (const auto& flag : serviceFlagsToStr(services)) {
|
||||
servicesNames.push_back(flag);
|
||||
}
|
||||
|
||||
return servicesNames;
|
||||
|
||||
Reference in New Issue
Block a user