aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-08-23 18:19:25 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-08-23 18:19:52 +0200
commitdbcb5742c48fd26f77e500291d7083e12eec741b (patch)
treea7785d1e84419e70ebe9eebbe3e770b67fd638de /src/protocol.h
parentf6f7a12462b381945b1cb9bcb94b129d8fb7e289 (diff)
parent75290ae61e37f9b7c432b59d03eca6f07f7529cd (diff)
downloadbitcoin-dbcb5742c48fd26f77e500291d7083e12eec741b.tar.xz
Merge bitcoin/bitcoin#20541: Move special CAddress-without-nTime logic to net_processing
75290ae61e37f9b7c432b59d03eca6f07f7529cd Drop us=... message in net debug for sending version message (Pieter Wuille) 5d47860334fbe0018e742d8d2a339deb11a899e8 refactor: move CAddress-without-nTime logic to net_processing (Pieter Wuille) Pull request description: Historically, the VERSION message contains an "addrMe" and an "addrYou". As these are sent before version negotiation is complete, the protocol version is INIT_PROTO_VERSION (209), and in that protocol, CAddress is serialized without nTime. This is in fact the only situation left where a CAddress is (de)serialized without nTime. As it's such a simple structure (CService for ip/port + uint64_t for nServices), just inline that structure in the few places where it occurs, and remove the logic for dealing with missing nTime from CAddress. ACKs for top commit: Zero-1729: crACK 75290ae61e37f9b7c432b59d03eca6f07f7529cd jonatack: ACK 75290ae61e37f9b7c432b59d03eca6f07f7529cd vasild: ACK 75290ae61e37f9b7c432b59d03eca6f07f7529cd Tree-SHA512: ccd9f478e1766fb2ad845d512b090e6297b82100640545ca490d930785801da3b429d40400bc2eb2cbe9057d5d12362ab33f8d650a1ca9e9e85857aef36ec414
Diffstat (limited to 'src/protocol.h')
-rw-r--r--src/protocol.h11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/protocol.h b/src/protocol.h
index f9248899dc..126c3646a4 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -396,7 +396,6 @@ public:
// ambiguous what that would mean. Make sure no code relying on that is introduced:
assert(!(s.GetType() & SER_GETHASH));
bool use_v2;
- bool store_time;
if (s.GetType() & SER_DISK) {
// In the disk serialization format, the encoding (v1 or v2) is determined by a flag version
// that's part of the serialization itself. ADDRV2_FORMAT in the stream version only determines
@@ -413,24 +412,16 @@ public:
} else {
throw std::ios_base::failure("Unsupported CAddress disk format version");
}
- store_time = true;
} else {
// In the network serialization format, the encoding (v1 or v2) is determined directly by
// the value of ADDRV2_FORMAT in the stream version, as no explicitly encoded version
// exists in the stream.
assert(s.GetType() & SER_NETWORK);
use_v2 = s.GetVersion() & ADDRV2_FORMAT;
- // The only time we serialize a CAddress object without nTime is in
- // the initial VERSION messages which contain two CAddress records.
- // At that point, the serialization version is INIT_PROTO_VERSION.
- // After the version handshake, serialization version is >=
- // MIN_PEER_PROTO_VERSION and all ADDR messages are serialized with
- // nTime.
- store_time = s.GetVersion() != INIT_PROTO_VERSION;
}
SER_READ(obj, obj.nTime = TIME_INIT);
- if (store_time) READWRITE(obj.nTime);
+ READWRITE(obj.nTime);
// nServices is serialized as CompactSize in V2; as uint64_t in V1.
if (use_v2) {
uint64_t services_tmp;