diff options
author | Pieter Wuille <pieter@wuille.net> | 2020-10-12 14:20:28 -0700 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2020-10-12 15:15:28 -0700 |
commit | 883cea7dea3cedc9b45b6191f7d4e7be2d9a11ca (patch) | |
tree | 10dc409a242a4b877dd79deec941654aca7bb40d /src | |
parent | 0b2abaa666d6f3331e3246ffd64dd47946e9dcdf (diff) | |
download | bitcoin-883cea7dea3cedc9b45b6191f7d4e7be2d9a11ca.tar.xz |
Restore compatibility with old CSubNet serialization
Diffstat (limited to 'src')
-rw-r--r-- | src/netaddress.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/netaddress.h b/src/netaddress.h index 3bcf6d35ca..aea0875511 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -468,7 +468,21 @@ class CSubNet friend bool operator!=(const CSubNet& a, const CSubNet& b) { return !(a == b); } friend bool operator<(const CSubNet& a, const CSubNet& b); - SERIALIZE_METHODS(CSubNet, obj) { READWRITE(obj.network, obj.netmask, obj.valid); } + SERIALIZE_METHODS(CSubNet, obj) + { + READWRITE(obj.network); + if (obj.network.IsIPv4()) { + // Before commit 102867c587f5f7954232fb8ed8e85cda78bb4d32, CSubNet used the last 4 bytes of netmask + // to store the relevant bytes for an IPv4 mask. For compatiblity reasons, keep doing so in + // serialized form. + unsigned char dummy[12] = {0}; + READWRITE(dummy); + READWRITE(MakeSpan(obj.netmask).first(4)); + } else { + READWRITE(obj.netmask); + } + READWRITE(obj.valid); + } }; /** A combination of a network address (CNetAddr) and a (TCP) port */ |