diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2023-06-01 10:27:33 -0400 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2023-06-01 10:27:33 -0400 |
commit | 5cd0717a54ce7a2065b29d90717aa2eb1c5e302d (patch) | |
tree | 0761d026c0d5ff837b320ab6891bb689e2fe8924 /src/streams.h | |
parent | 3a83d4417b35cb0173286b6da97315be861901bc (diff) | |
download | bitcoin-5cd0717a54ce7a2065b29d90717aa2eb1c5e302d.tar.xz |
streams: Drop confusing DataStream::Serialize method and << operator
DataStream Serialize method has surprising behavior because it just serializes
raw bytes without a length prefix. When you serialize a string or vector, a
length prefix is serialized before the raw object contents so the object can be
unambiguously deserialized later. But DataStreams don't support deserializing
at all and just dump the raw bytes.
Having this inconsistency is not necessary and could be confusing (see
https://github.com/bitcoin/bitcoin/pull/27790#discussion_r1212315030) so this
PR just drops the DataStream::Serialize method.
Diffstat (limited to 'src/streams.h')
-rw-r--r-- | src/streams.h | 8 |
1 files changed, 0 insertions, 8 deletions
diff --git a/src/streams.h b/src/streams.h index e346aa0a3f..03df20b5db 100644 --- a/src/streams.h +++ b/src/streams.h @@ -293,14 +293,6 @@ public: vch.insert(vch.end(), src.begin(), src.end()); } - template<typename Stream> - void Serialize(Stream& s) const - { - // Special case: stream << stream concatenates like stream += stream - if (!vch.empty()) - s.write(MakeByteSpan(vch)); - } - template<typename T> DataStream& operator<<(const T& obj) { |