Do not access CNetAddr::ip
directly from CService
methods.
This improvement will help later when we change the type of
CNetAddr::ip
(in the BIP155 implementation).
(chopped off from #19031 to ease review)
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
No conflicts as of last run.
Do not access `CNetAddr::ip` directly from `CService` methods.
This improvement will help later when we change the type of
`CNetAddr::ip` (in the BIP155 implementation).
Co-authored-by: Carl Dong <contact@carldong.me>
Updated to use CNetAddr::GetAddrBytes()
, see #19031 (comment) for longer explanation.
Now this PR is even simpler.
ACK bc74a40a56128f81f11151d5966f53b82f19038c
Restarted Travis job
730- vKey.resize(18);
731- memcpy(vKey.data(), ip, 16);
732- vKey[16] = port / 0x100; // most significant byte of our port
733- vKey[17] = port & 0x0FF; // least significant byte of our port
734- return vKey;
735+ auto key = GetAddrBytes();
auto
, but if this is critical code, maybe it would be prudent to use the explicit std::vector<unsigned char>
type.
159@@ -160,7 +160,11 @@ class CService : public CNetAddr
160 CService(const struct in6_addr& ipv6Addr, uint16_t port);
161 explicit CService(const struct sockaddr_in6& addr);
162
163- SERIALIZE_METHODS(CService, obj) { READWRITE(obj.ip, Using<BigEndianFormatter<2>>(obj.port)); }
164+ SERIALIZE_METHODS(CService, obj)
165+ {
166+ READWRITEAS(CNetAddr, obj);