MCPcopy Create free account
hub / github.com/ElementsProject/elements / serviceFlagToStr

Function serviceFlagToStr

src/protocol.cpp:189–209  ·  view source on GitHub ↗

* 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) */

Source from the content-addressed store, hash-verified

187 * @param[in] bit the service flag is calculated as (1 << bit)
188 */
189static std::string serviceFlagToStr(size_t bit)
190{
191 const uint64_t service_flag = 1ULL << bit;
192 switch ((ServiceFlags)service_flag) {
193 case NODE_NONE: abort(); // impossible
194 case NODE_NETWORK: return "NETWORK";
195 case NODE_BLOOM: return "BLOOM";
196 case NODE_WITNESS: return "WITNESS";
197 case NODE_COMPACT_FILTERS: return "COMPACT_FILTERS";
198 case NODE_NETWORK_LIMITED: return "NETWORK_LIMITED";
199 case NODE_REPLACE_BY_FEE: return "REPLACE_BY_FEE";
200 // Not using default, so we get warned when a case is missing
201 }
202
203 std::ostringstream stream;
204 stream.imbue(std::locale::classic());
205 stream << "UNKNOWN[";
206 stream << "2^" << bit;
207 stream << "]";
208 return stream.str();
209}
210
211std::vector<std::string> serviceFlagsToStr(uint64_t flags)
212{

Callers 1

serviceFlagsToStrFunction · 0.85

Calls 1

strMethod · 0.80

Tested by

no test coverage detected