Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.cpp
Show First 20 Lines • Show All 749 Lines • ▼ Show 20 Lines | bool CService::GetSockAddr(struct sockaddr *paddr, socklen_t *addrlen) const { | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* @returns An identifier unique to this service's address and port number. | * @returns An identifier unique to this service's address and port number. | ||||
*/ | */ | ||||
std::vector<uint8_t> CService::GetKey() const { | std::vector<uint8_t> CService::GetKey() const { | ||||
std::vector<uint8_t> vKey; | auto key = GetAddrBytes(); | ||||
vKey.resize(18); | |||||
memcpy(vKey.data(), ip, 16); | |||||
// most significant byte of our port | // most significant byte of our port | ||||
vKey[16] = port / 0x100; | key.push_back(port / 0x100); | ||||
// least significant byte of our port | // least significant byte of our port | ||||
vKey[17] = port & 0x0FF; | key.push_back(port & 0x0FF); | ||||
return vKey; | return key; | ||||
} | } | ||||
std::string CService::ToStringPort() const { | std::string CService::ToStringPort() const { | ||||
return strprintf("%u", port); | return strprintf("%u", port); | ||||
} | } | ||||
std::string CService::ToStringIPPort() const { | std::string CService::ToStringIPPort() const { | ||||
if (IsIPv4() || IsTor() || IsInternal()) { | if (IsIPv4() || IsTor() || IsInternal()) { | ||||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |