mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Remove unused (and broken) functionality in SpanReader
This removes the ability to set an offset in the SpanReader constructor,
as the current code is broken. All call sites use pos=0, so it is actually
unused. If future call sites need it, SpanReader{a, b, c, d} is equivalent
to SpanReader{a, b, c.subspan(d)}.
It also removes the ability to deserialize from SpanReader directly from
the constructor. This too is unused, and can be more idiomatically
simulated using (SpanReader{a, b, c} >> x >> y >> z) instead of
SpanReader{a, b, c, x, y, z}.
This commit is contained in:
@@ -143,28 +143,9 @@ public:
|
||||
* @param[in] type Serialization Type
|
||||
* @param[in] version Serialization Version (including any flags)
|
||||
* @param[in] data Referenced byte vector to overwrite/append
|
||||
* @param[in] pos Starting position. Vector index where reads should start.
|
||||
*/
|
||||
SpanReader(int type, int version, Span<const unsigned char> data, size_t pos)
|
||||
: m_type(type), m_version(version), m_data(data)
|
||||
{
|
||||
if (pos > m_data.size()) {
|
||||
throw std::ios_base::failure("SpanReader(...): end of data (pos > m_data.size())");
|
||||
}
|
||||
data = data.subspan(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* (other params same as above)
|
||||
* @param[in] args A list of items to deserialize starting at pos.
|
||||
*/
|
||||
template <typename... Args>
|
||||
SpanReader(int type, int version, Span<const unsigned char> data, size_t pos,
|
||||
Args&&... args)
|
||||
: SpanReader(type, version, data, pos)
|
||||
{
|
||||
::UnserializeMany(*this, std::forward<Args>(args)...);
|
||||
}
|
||||
SpanReader(int type, int version, Span<const unsigned char> data)
|
||||
: m_type(type), m_version(version), m_data(data) {}
|
||||
|
||||
template<typename T>
|
||||
SpanReader& operator>>(T&& obj)
|
||||
|
||||
Reference in New Issue
Block a user