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.
This commit is contained in:
Ryan Ofsky
2023-06-01 10:27:33 -04:00
parent 3a83d4417b
commit 5cd0717a54
4 changed files with 4 additions and 18 deletions

View File

@@ -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)
{