Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: save the network type explicitly in CNetAddr #19534

Merged
merged 2 commits into from
Jul 29, 2020

Commits on Jul 20, 2020

  1. net: document enum Network

    vasild committed Jul 20, 2020
    Configuration menu
    Copy the full SHA
    100c64a View commit details
    Browse the repository at this point in the history

Commits on Jul 27, 2020

  1. net: save the network type explicitly in CNetAddr

    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`.
    
    Co-authored-by: Carl Dong <contact@carldong.me>
    vasild and dongcarl committed Jul 27, 2020
    Configuration menu
    Copy the full SHA
    bcfebb6 View commit details
    Browse the repository at this point in the history