Skip to content

Commit 950af7c

Browse files
committed
Merge bitcoin/bitcoin#28878: Remove version field from GetSerializeSize
83986f4 Include version.h in fewer places (Anthony Towns) c7b61fd Convert some CDataStream to DataStream (Anthony Towns) 1410d30 serialize: Drop useless version param from GetSerializeSize() (Anthony Towns) bf574a7 serialize: drop GetSerializeSizeMany (Anthony Towns) efa9eb6 serialize: Drop nVersion from [C]SizeComputer (Anthony Towns) Pull request description: Drops the version field from `GetSerializeSize()`, simplifying the code in various places. Also drop `GetSerializeSizeMany()` (as just removing the version parameter could result in silent bugs) and remove unnecessary instances of `#include <version.h>`. ACKs for top commit: maflcko: ACK 83986f4 📒 theuni: ACK 83986f4. Tree-SHA512: 36617b6dfbb1b4b0afbf673e905525fc6d623d3f568d3f86e3b9d4f69820db97d099e83a88007bfff881f731ddca6755ebf1549e8d8a7762437dfadbf434c62e
2 parents afd3e99 + 83986f4 commit 950af7c

34 files changed

+69
-81
lines changed

src/bench/checkblock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
static void DeserializeBlockTest(benchmark::Bench& bench)
2020
{
21-
CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
21+
DataStream stream(benchmark::data::block413567);
2222
std::byte a{0};
2323
stream.write({&a, 1}); // Prevent compaction
2424

@@ -32,7 +32,7 @@ static void DeserializeBlockTest(benchmark::Bench& bench)
3232

3333
static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
3434
{
35-
CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
35+
DataStream stream(benchmark::data::block413567);
3636
std::byte a{0};
3737
stream.write({&a, 1}); // Prevent compaction
3838

src/bench/verify_script.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void VerifyScriptBench(benchmark::Bench& bench)
6161
assert(success);
6262

6363
#if defined(HAVE_CONSENSUS_LIB)
64-
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
64+
DataStream stream;
6565
stream << TX_WITH_WITNESS(txSpend);
6666
int csuccess = bitcoinconsensus_verify_script_with_amount(
6767
txCredit.vout[0].scriptPubKey.data(),

src/bitcoin-util.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <util/exception.h>
2020
#include <util/strencodings.h>
2121
#include <util/translation.h>
22-
#include <version.h>
2322

2423
#include <atomic>
2524
#include <cstdio>

src/blockencodings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
164164
break;
165165
}
166166

167-
LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock, PROTOCOL_VERSION));
167+
LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock));
168168

169169
return READ_STATUS_OK;
170170
}

src/coins.cpp

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

1312
bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return false; }
1413
uint256 CCoinsView::GetBestBlock() const { return uint256(); }
@@ -339,7 +338,7 @@ void CCoinsViewCache::SanityCheck() const
339338
assert(recomputed_usage == cachedCoinsUsage);
340339
}
341340

342-
static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut(), PROTOCOL_VERSION);
341+
static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut());
343342
static const size_t MAX_OUTPUTS_PER_BLOCK = MAX_BLOCK_WEIGHT / MIN_TRANSACTION_OUTPUT_WEIGHT;
344343

345344
const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)

src/consensus/validation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#define BITCOIN_CONSENSUS_VALIDATION_H
88

99
#include <string>
10-
#include <version.h>
1110
#include <consensus/consensus.h>
1211
#include <primitives/transaction.h>
1312
#include <primitives/block.h>

src/core_read.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <streams.h>
1313
#include <util/result.h>
1414
#include <util/strencodings.h>
15-
#include <version.h>
1615

1716
#include <algorithm>
1817
#include <string>

src/external_signer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#include <external_signer.h>
6+
57
#include <chainparams.h>
68
#include <common/run_command.h>
79
#include <core_io.h>
810
#include <psbt.h>
911
#include <util/strencodings.h>
10-
#include <external_signer.h>
12+
#include <version.h>
1113

1214
#include <algorithm>
1315
#include <stdexcept>

src/hash.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <serialize.h>
1515
#include <span.h>
1616
#include <uint256.h>
17-
#include <version.h>
1817

1918
#include <string>
2019
#include <vector>

src/index/blockfilterindex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ size_t BlockFilterIndex::WriteFilterToDisk(FlatFilePos& pos, const BlockFilter&
174174
assert(filter.GetFilterType() == GetFilterType());
175175

176176
size_t data_size =
177-
GetSerializeSize(filter.GetBlockHash(), CLIENT_VERSION) +
178-
GetSerializeSize(filter.GetEncodedFilter(), CLIENT_VERSION);
177+
GetSerializeSize(filter.GetBlockHash()) +
178+
GetSerializeSize(filter.GetEncodedFilter());
179179

180180
// If writing the filter would overflow the file, flush and move to the next one.
181181
if (pos.nPos + data_size > MAX_FLTR_FILE_SIZE) {

0 commit comments

Comments
 (0)