diff options
author | fanquake <fanquake@gmail.com> | 2023-10-02 12:17:54 +0200 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-10-02 12:33:54 +0200 |
commit | 48b8910d12afd2643de1e98fcf33206ea2d6cad8 (patch) | |
tree | 0363648c23187c8e01b47a3fc9e9ace80e7408f7 /src/streams.h | |
parent | 0f9307c4cbaeb605acb0584f3677009d2962f0a4 (diff) | |
parent | fac29a0ab19fda457b55d7a0a37c5cd3d9680f82 (diff) | |
download | bitcoin-48b8910d12afd2643de1e98fcf33206ea2d6cad8.tar.xz |
Merge bitcoin/bitcoin#28508: refactor: Remove SER_GETHASH, hard-code client version in CKeyPool serialize
fac29a0ab19fda457b55d7a0a37c5cd3d9680f82 Remove SER_GETHASH, hard-code client version in CKeyPool serialize (MarcoFalke)
fa72f09d6ff8ee204f331a69d3f5e825223c9e11 Remove CHashWriter type (MarcoFalke)
fa4a9c0f4334678fb80358ead667807bf2a0a153 Remove unused GetType() from OverrideStream, CVectorWriter, SpanReader (MarcoFalke)
Pull request description:
Removes a bunch of redundant, dead or duplicate code.
Uses the idea from and finishes the idea https://github.com/bitcoin/bitcoin/pull/28428 by theuni
ACKs for top commit:
ajtowns:
ACK fac29a0ab19fda457b55d7a0a37c5cd3d9680f82
kevkevinpal:
added one nit but otherwise ACK [fac29a0](https://github.com/bitcoin/bitcoin/pull/28508/commits/fac29a0ab19fda457b55d7a0a37c5cd3d9680f82)
Tree-SHA512: cc805e2f38e73869a6691fdb5da09fa48524506b87fc93f05d32c336ad3033425a2d7608e317decd3141fde3f084403b8de280396c0c39132336fe0f7510af9e
Diffstat (limited to 'src/streams.h')
-rw-r--r-- | src/streams.h | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/streams.h b/src/streams.h index e069719d89..d58de5233b 100644 --- a/src/streams.h +++ b/src/streams.h @@ -50,11 +50,10 @@ class OverrideStream { Stream* stream; - const int nType; const int nVersion; public: - OverrideStream(Stream* stream_, int nType_, int nVersion_) : stream(stream_), nType(nType_), nVersion(nVersion_) {} + OverrideStream(Stream* stream_, int nVersion_) : stream{stream_}, nVersion{nVersion_} {} template<typename T> OverrideStream<Stream>& operator<<(const T& obj) @@ -81,7 +80,6 @@ public: } int GetVersion() const { return nVersion; } - int GetType() const { return nType; } size_t size() const { return stream->size(); } void ignore(size_t size) { return stream->ignore(size); } }; @@ -95,13 +93,12 @@ class CVectorWriter public: /* - * @param[in] nTypeIn Serialization Type * @param[in] nVersionIn Serialization Version (including any flags) * @param[in] vchDataIn Referenced byte vector to overwrite/append * @param[in] nPosIn Starting position. Vector index where writes should start. The vector will initially * grow as necessary to max(nPosIn, vec.size()). So to append, use vec.size(). */ - CVectorWriter(int nTypeIn, int nVersionIn, std::vector<unsigned char>& vchDataIn, size_t nPosIn) : nType(nTypeIn), nVersion(nVersionIn), vchData(vchDataIn), nPos(nPosIn) + CVectorWriter(int nVersionIn, std::vector<unsigned char>& vchDataIn, size_t nPosIn) : nVersion{nVersionIn}, vchData{vchDataIn}, nPos{nPosIn} { if(nPos > vchData.size()) vchData.resize(nPos); @@ -111,7 +108,7 @@ class CVectorWriter * @param[in] args A list of items to serialize starting at nPosIn. */ template <typename... Args> - CVectorWriter(int nTypeIn, int nVersionIn, std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : CVectorWriter(nTypeIn, nVersionIn, vchDataIn, nPosIn) + CVectorWriter(int nVersionIn, std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : CVectorWriter{nVersionIn, vchDataIn, nPosIn} { ::SerializeMany(*this, std::forward<Args>(args)...); } @@ -137,12 +134,8 @@ class CVectorWriter { return nVersion; } - int GetType() const - { - return nType; - } + private: - const int nType; const int nVersion; std::vector<unsigned char>& vchData; size_t nPos; @@ -153,19 +146,16 @@ private: class SpanReader { private: - const int m_type; const int m_version; Span<const unsigned char> m_data; public: - /** - * @param[in] type Serialization Type * @param[in] version Serialization Version (including any flags) * @param[in] data Referenced byte vector to overwrite/append */ - SpanReader(int type, int version, Span<const unsigned char> data) - : m_type(type), m_version(version), m_data(data) {} + SpanReader(int version, Span<const unsigned char> data) + : m_version{version}, m_data{data} {} template<typename T> SpanReader& operator>>(T&& obj) @@ -175,7 +165,6 @@ public: } int GetVersion() const { return m_version; } - int GetType() const { return m_type; } size_t size() const { return m_data.size(); } bool empty() const { return m_data.empty(); } |