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:
Vasil Dimov
2020-05-29 18:52:59 +02:00
parent fbacad1880
commit 189ae0c38b
4 changed files with 26 additions and 16 deletions

View File

@@ -289,11 +289,11 @@ enum ServiceFlags : uint64_t {
};
/**
* Convert a service flag (NODE_*) to a human readable string.
* Convert service flags (a bitmask of NODE_*) to human readable strings.
* It supports unknown service flags which will be returned as "UNKNOWN[...]".
* @param[in] bit the service flag is calculated as (1 << bit)
* @param[in] flags multiple NODE_* bitwise-OR-ed together
*/
std::string serviceFlagToStr(size_t bit);
std::vector<std::string> serviceFlagsToStr(uint64_t flags);
/**
* Gets the set of service flags which are "desirable" for a given peer.