mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge #18165: Consolidate service flag bit-to-name conversion to a shared serviceFlagToStr function
c31bc5bcfdConsolidate service flag bit-to-name conversion to a shared serviceFlagToStr function (Luke Dashjr)cea91a1e40Bugfix: GUI: Use unsigned long long type to avoid implicit conversion of MSB check (Luke Dashjr) Pull request description: 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. ACKs for top commit: jonasschnelli: utACK ~~cea91a1e40~~c31bc5bcfdTree-SHA512: 32c7ba8ac7ef2d4087f4f317447ae93a328ec9fb9ad81301df2fbaeeb21a3db7a503187a369552b05a9414251b7cf8e15bcde74c1ea2ef36591ea7ffb6721f60
This commit is contained in:
commit
de369c7ea5
4 changed files with 36 additions and 31 deletions
|
|
@ -194,3 +194,27 @@ const std::vector<std::string> &getAllNetMessageTypes()
|
|||
{
|
||||
return allNetMessageTypesVec;
|
||||
}
|
||||
|
||||
std::string serviceFlagToStr(const uint64_t mask, const int bit)
|
||||
{
|
||||
switch (ServiceFlags(mask)) {
|
||||
case NODE_NONE: abort(); // impossible
|
||||
case NODE_NETWORK: return "NETWORK";
|
||||
case NODE_GETUTXO: return "GETUTXO";
|
||||
case NODE_BLOOM: return "BLOOM";
|
||||
case NODE_WITNESS: return "WITNESS";
|
||||
case NODE_NETWORK_LIMITED: return "NETWORK_LIMITED";
|
||||
// Not using default, so we get warned when a case is missing
|
||||
}
|
||||
|
||||
std::ostringstream stream;
|
||||
stream.imbue(std::locale::classic());
|
||||
stream << "UNKNOWN[";
|
||||
if (bit < 8) {
|
||||
stream << mask;
|
||||
} else {
|
||||
stream << "2^" << bit;
|
||||
}
|
||||
stream << "]";
|
||||
return stream.str();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue