MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ToString

Method ToString

src/netaddress.cpp:1047–1078  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045}
1046
1047std::string CSubNet::ToString() const
1048{
1049 std::string suffix;
1050
1051 switch (network.m_net) {
1052 case NET_IPV4:
1053 case NET_IPV6: {
1054 assert(network.m_addr.size() <= sizeof(netmask));
1055
1056 uint8_t cidr = 0;
1057
1058 for (size_t i = 0; i < network.m_addr.size(); ++i) {
1059 if (netmask[i] == 0x00) {
1060 break;
1061 }
1062 cidr += NetmaskBits(netmask[i]);
1063 }
1064
1065 suffix = strprintf("/%u", cidr);
1066 break;
1067 }
1068 case NET_ONION:
1069 case NET_I2P:
1070 case NET_CJDNS:
1071 case NET_INTERNAL:
1072 case NET_UNROUTABLE:
1073 case NET_MAX:
1074 break;
1075 }
1076
1077 return network.ToStringAddr() + suffix;
1078}
1079
1080bool CSubNet::IsValid() const
1081{

Callers

nothing calls this directly

Calls 3

NetmaskBitsFunction · 0.85
ToStringAddrMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected