Skip to content

Commit ffb0216

Browse files
committed
Merge bitcoin/bitcoin#28451: refactor: Remove unused SER_DISK, SER_NETWORK, CDataStream
fa98a09 Rename version.h to node/protocol_version.h (MarcoFalke) fa4fbd5 Remove unused version.h include (MarcoFalke) fa0ae22 Remove unused SER_NETWORK, SER_DISK (MarcoFalke) fae00fe Remove unused CDataStream (MarcoFalke) fa7eb4f fuzz: Drop unused version from fuzz input format (MarcoFalke) Pull request description: Seems odd to have code that is completely dead. Fix this by removing all of it. ACKs for top commit: sipa: utACK fa98a09 ajtowns: ACK fa98a09 ryanofsky: Seems odd to not code review ACK fa98a09 (looks good) Tree-SHA512: 9f1b9d9f92bda0512610bda6653e892756f637860362a9abfa439faab62de233cbad94b7df78ebacc160d9667aadfed4d9df08c0edefa618c040a049050fb913
2 parents cdb7723 + fa98a09 commit ffb0216

38 files changed

+69
-138
lines changed

src/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ BITCOIN_CORE_H = \
230230
node/mini_miner.h \
231231
node/minisketchwrapper.h \
232232
node/peerman_args.h \
233+
node/protocol_version.h \
233234
node/psbt.h \
234235
node/transaction.h \
235236
node/txreconciliation.h \
@@ -658,8 +659,7 @@ libbitcoin_consensus_a_SOURCES = \
658659
uint256.cpp \
659660
uint256.h \
660661
util/strencodings.cpp \
661-
util/strencodings.h \
662-
version.h
662+
util/strencodings.h
663663
#
664664

665665
# common #

src/bench/rpc_blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct TestBlockAndIndex {
2323

2424
TestBlockAndIndex()
2525
{
26-
CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
26+
DataStream stream{benchmark::data::block413567};
2727
std::byte a{0};
2828
stream.write({&a, 1}); // Prevent compaction
2929

src/external_signer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <core_io.h>
1010
#include <psbt.h>
1111
#include <util/strencodings.h>
12-
#include <version.h>
1312

1413
#include <algorithm>
1514
#include <stdexcept>

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <netbase.h>
2121
#include <netgroup.h>
2222
#include <node/connection_types.h>
23+
#include <node/protocol_version.h>
2324
#include <policy/feerate.h>
2425
#include <protocol.h>
2526
#include <random.h>
@@ -30,7 +31,6 @@
3031
#include <util/check.h>
3132
#include <util/sock.h>
3233
#include <util/threadinterrupt.h>
33-
#include <version.h>
3434

3535
#include <atomic>
3636
#include <condition_variable>

src/version.h renamed to src/node/protocol_version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright (c) 2012-2020 The Bitcoin Core developers
1+
// Copyright (c) 2012-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#ifndef BITCOIN_VERSION_H
6-
#define BITCOIN_VERSION_H
5+
#ifndef BITCOIN_NODE_PROTOCOL_VERSION_H
6+
#define BITCOIN_NODE_PROTOCOL_VERSION_H
77

88
/**
99
* network protocol versioning
@@ -35,4 +35,4 @@ static const int INVALID_CB_NO_BAN_VERSION = 70015;
3535
//! "wtxidrelay" command for wtxid-based relay starts with this version
3636
static const int WTXID_RELAY_VERSION = 70016;
3737

38-
#endif // BITCOIN_VERSION_H
38+
#endif // BITCOIN_NODE_PROTOCOL_VERSION_H

src/psbt.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <script/signingprovider.h>
99
#include <util/check.h>
1010
#include <util/strencodings.h>
11-
#include <version.h>
1211

1312

1413
PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx) : tx(tx)
@@ -546,7 +545,7 @@ bool DecodeBase64PSBT(PartiallySignedTransaction& psbt, const std::string& base6
546545

547546
bool DecodeRawPSBT(PartiallySignedTransaction& psbt, Span<const std::byte> tx_data, std::string& error)
548547
{
549-
CDataStream ss_data(tx_data, SER_NETWORK, PROTOCOL_VERSION);
548+
DataStream ss_data{tx_data};
550549
try {
551550
ss_data >> psbt;
552551
if (!ss_data.empty()) {

src/rpc/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <net_types.h> // For banmap_t
1616
#include <netbase.h>
1717
#include <node/context.h>
18+
#include <node/protocol_version.h>
1819
#include <policy/settings.h>
1920
#include <protocol.h>
2021
#include <rpc/blockchain.h>
@@ -29,7 +30,6 @@
2930
#include <util/time.h>
3031
#include <util/translation.h>
3132
#include <validation.h>
32-
#include <version.h>
3333
#include <warnings.h>
3434

3535
#include <optional>

src/rpc/rawtransaction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include <util/vector.h>
4141
#include <validation.h>
4242
#include <validationinterface.h>
43-
#include <version.h>
4443

4544
#include <numeric>
4645
#include <stdint.h>

src/serialize.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,8 @@ template<typename Stream> inline uint64_t ser_readdata64(Stream &s)
117117
}
118118

119119

120-
/////////////////////////////////////////////////////////////////
121-
//
122-
// Templates for serializing to anything that looks like a stream,
123-
// i.e. anything that supports .read(Span<std::byte>) and .write(Span<const std::byte>)
124-
//
125-
126120
class SizeComputer;
127121

128-
enum
129-
{
130-
// primary actions
131-
SER_NETWORK = (1 << 0),
132-
SER_DISK = (1 << 1),
133-
};
134-
135122
/**
136123
* Convert any argument to a reference to X, maintaining constness.
137124
*
@@ -268,6 +255,9 @@ const Out& AsBase(const In& x)
268255
BASE_SERIALIZE_METHODS(cls) \
269256
FORMATTER_METHODS_PARAMS(cls, obj, paramcls, paramobj)
270257

258+
// Templates for serializing to anything that looks like a stream,
259+
// i.e. anything that supports .read(Span<std::byte>) and .write(Span<const std::byte>)
260+
//
271261
// clang-format off
272262
#ifndef CHAR_EQUALS_INT8
273263
template <typename Stream> void Serialize(Stream&, char) = delete; // char serialization forbidden. Use uint8_t or int8_t

src/streams.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -279,42 +279,6 @@ class DataStream
279279
}
280280
};
281281

282-
class CDataStream : public DataStream
283-
{
284-
private:
285-
int nType;
286-
int nVersion;
287-
288-
public:
289-
explicit CDataStream(int nTypeIn, int nVersionIn)
290-
: nType{nTypeIn},
291-
nVersion{nVersionIn} {}
292-
293-
explicit CDataStream(Span<const uint8_t> sp, int type, int version) : CDataStream{AsBytes(sp), type, version} {}
294-
explicit CDataStream(Span<const value_type> sp, int nTypeIn, int nVersionIn)
295-
: DataStream{sp},
296-
nType{nTypeIn},
297-
nVersion{nVersionIn} {}
298-
299-
int GetType() const { return nType; }
300-
void SetVersion(int n) { nVersion = n; }
301-
int GetVersion() const { return nVersion; }
302-
303-
template <typename T>
304-
CDataStream& operator<<(const T& obj)
305-
{
306-
::Serialize(*this, obj);
307-
return *this;
308-
}
309-
310-
template <typename T>
311-
CDataStream& operator>>(T&& obj)
312-
{
313-
::Unserialize(*this, obj);
314-
return *this;
315-
}
316-
};
317-
318282
template <typename IStream>
319283
class BitStreamReader
320284
{

0 commit comments

Comments
 (0)