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)
All modified code is covered by existent tests. For example: CService::GetKey().
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
utACK 567f98ea5d33d8cec699148be83b079dd5189101
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();
I like auto, but if this is critical code, maybe it would be prudent to use the explicit std::vector<unsigned char> type.
ACK bc74a40a56128f81f11151d5966f53b82f19038c
ACK bc74a40
Code review ACK bc74a40
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);
ACK bc74a40a5
code review ACK bc74a40a56128f81f11151d5966f53b82f19038c