mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 01:33:20 +02:00
Merge #19106: util: simplify the interface of serviceFlagToStr()
189ae0c38butil: dedup code in callers of serviceFlagToStr() (Vasil Dimov)fbacad1880util: simplify the interface of serviceFlagToStr() (Vasil Dimov) Pull request description: Don't take two redundant arguments in `serviceFlagToStr()`. Introduce `serviceFlagsToStr()` which takes a mask (with more than one bit set) and returns a vector of strings. As a side effect this fixes an issue introduced in https://github.com/bitcoin/bitcoin/pull/18165 due to which the GUI could print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]` instead of `NETWORK & WITNESS`. ACKs for top commit: MarcoFalke: ACK189ae0c38bjonasschnelli: Tested ACK189ae0c38bTree-SHA512: 000c490f16ebbba04458c62ca4ce743abffd344d375d95f5bbd5008742012032787655db2874b168df0270743266261dccf1693761906567502dcbac902bda50
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(mask, i));
|
||||
}
|
||||
for (const auto& flag : serviceFlagsToStr(services)) {
|
||||
servicesNames.push_back(flag);
|
||||
}
|
||||
|
||||
return servicesNames;
|
||||
|
||||
Reference in New Issue
Block a user