Page MenuHomePhabricator

net: save the network type explicitly in CNetAddr
ClosedPublic

Authored by Fabien on Thu, Feb 4, 17:05.

Details

Reviewers
majcosta
Group Reviewers
Restricted Project
Commits
rABCb4c94da5b58e: net: save the network type explicitly in CNetAddr
Summary
Before this change, we would analyze the contents of CNetAddr::ip[16]
in order to tell which type is an address. Change this by introducing a
new member CNetAddr::m_net that explicitly tells the type of the
address.

This is necessary because in BIP155 we will not be able to tell the
address type by just looking at its raw representation (e.g. both TORv3
and I2P are "seemingly random" 32 bytes).

As a side effect of this change we no longer need to store IPv4
addresses encoded as IPv6 addresses - we can store them in proper 4
bytes (will be done in a separate commit). Also the code gets
somewhat simplified - instead of
memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0 we can use
m_net == NET_IPV4.

Backport of core PR19534.

Depends on D9170 and D9171.

Test Plan
ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.