Changeset View
Changeset View
Standalone View
Standalone View
src/protocol.cpp
Show First 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | try { | ||||
return strprintf("0x%08x %s", type, hash.ToString()); | return strprintf("0x%08x %s", type, hash.ToString()); | ||||
} | } | ||||
} | } | ||||
const std::vector<std::string> &getAllNetMessageTypes() { | const std::vector<std::string> &getAllNetMessageTypes() { | ||||
return allNetMessageTypesVec; | return allNetMessageTypesVec; | ||||
} | } | ||||
std::string serviceFlagToStr(const uint64_t mask, const int bit) { | /** | ||||
switch (ServiceFlags(mask)) { | * Convert a service flag (NODE_*) to a human readable string. | ||||
* It supports unknown service flags which will be returned as "UNKNOWN[...]". | |||||
* @param[in] bit the service flag is calculated as (1 << bit) | |||||
*/ | |||||
static std::string serviceFlagToStr(const size_t bit) { | |||||
const uint64_t service_flag = 1ULL << bit; | |||||
switch (ServiceFlags(service_flag)) { | |||||
case NODE_NONE: | case NODE_NONE: | ||||
// impossible | // impossible | ||||
abort(); | abort(); | ||||
case NODE_NETWORK: | case NODE_NETWORK: | ||||
return "NETWORK"; | return "NETWORK"; | ||||
case NODE_GETUTXO: | case NODE_GETUTXO: | ||||
return "GETUTXO"; | return "GETUTXO"; | ||||
case NODE_BLOOM: | case NODE_BLOOM: | ||||
Show All 12 Lines | switch (ServiceFlags(service_flag)) { | ||||
stream << mask; | stream << mask; | ||||
} else { | } else { | ||||
stream << "2^" << bit; | stream << "2^" << bit; | ||||
} | } | ||||
stream << "]"; | stream << "]"; | ||||
return stream.str(); | return stream.str(); | ||||
} | } | ||||
} | } | ||||
std::vector<std::string> serviceFlagsToStr(const uint64_t flags) { | |||||
std::vector<std::string> str_flags; | |||||
for (size_t i = 0; i < sizeof(flags) * 8; ++i) { | |||||
if (flags & (1ULL << i)) { | |||||
str_flags.emplace_back(serviceFlagToStr(i)); | |||||
} | |||||
} | |||||
return str_flags; | |||||
} |