diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-11-23 18:53:44 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-11-23 21:19:22 +0100 |
commit | fa8bdb048e65cae2d26bea3f991717a856e2fb39 (patch) | |
tree | c29e6b49aef28d00725ae4477de2f4b7c5bdf1ca /src/streams.h | |
parent | faa96f841fe45bc49ebb6e07ac82a129fa9c40bf (diff) |
refactor: Drop CDataStream constructors in favor of one taking a Span of bytes
Diffstat (limited to 'src/streams.h')
-rw-r--r-- | src/streams.h | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/streams.h b/src/streams.h index 793c06b5c5..53924d76ed 100644 --- a/src/streams.h +++ b/src/streams.h @@ -6,8 +6,9 @@ #ifndef BITCOIN_STREAMS_H #define BITCOIN_STREAMS_H -#include <support/allocators/zeroafterfree.h> #include <serialize.h> +#include <span.h> +#include <support/allocators/zeroafterfree.h> #include <algorithm> #include <assert.h> @@ -15,8 +16,8 @@ #include <limits> #include <stdint.h> #include <stdio.h> -#include <string> #include <string.h> +#include <string> #include <utility> #include <vector> @@ -225,27 +226,8 @@ public: Init(nTypeIn, nVersionIn); } - CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend) - { - Init(nTypeIn, nVersionIn); - } - - CDataStream(const char* pbegin, const char* pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend) - { - Init(nTypeIn, nVersionIn); - } - - CDataStream(const vector_type& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end()) - { - Init(nTypeIn, nVersionIn); - } - - CDataStream(const std::vector<char>& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end()) - { - Init(nTypeIn, nVersionIn); - } - - CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end()) + explicit CDataStream(Span<const uint8_t> sp, int nTypeIn, int nVersionIn) + : vch(sp.data(), sp.data() + sp.size()) { Init(nTypeIn, nVersionIn); } @@ -289,7 +271,7 @@ public: value_type* data() { return vch.data() + nReadPos; } const value_type* data() const { return vch.data() + nReadPos; } - void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last) + void insert(iterator it, std::vector<uint8_t>::const_iterator first, std::vector<uint8_t>::const_iterator last) { if (last == first) return; assert(last - first > 0); |