Skip to content

Commit 1410d30

Browse files
committed
serialize: Drop useless version param from GetSerializeSize()
1 parent bf574a7 commit 1410d30

14 files changed

+43
-43
lines changed

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ void CCoinsViewCache::SanityCheck() const
339339
assert(recomputed_usage == cachedCoinsUsage);
340340
}
341341

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

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

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) {

src/node/blockstorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
662662
}
663663

664664
// Write index header
665-
unsigned int nSize = GetSerializeSize(blockundo, CLIENT_VERSION);
665+
unsigned int nSize = GetSerializeSize(blockundo);
666666
fileout << GetParams().MessageStart() << nSize;
667667

668668
// Write undo data
@@ -979,7 +979,7 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
979979
// Write undo information to disk
980980
if (block.GetUndoPos().IsNull()) {
981981
FlatFilePos _pos;
982-
if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo, CLIENT_VERSION) + 40)) {
982+
if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo) + 40)) {
983983
return error("ConnectBlock(): FindUndoPos failed");
984984
}
985985
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash())) {

src/rpc/blockchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ static RPCHelpMan getblockstats()
18611861
for (const CTxOut& out : tx->vout) {
18621862
tx_total_out += out.nValue;
18631863

1864-
size_t out_size = GetSerializeSize(out, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
1864+
size_t out_size = GetSerializeSize(out) + PER_UTXO_OVERHEAD;
18651865
utxo_size_inc += out_size;
18661866

18671867
// The Genesis block and the repeated BIP30 block coinbases don't change the UTXO
@@ -1913,7 +1913,7 @@ static RPCHelpMan getblockstats()
19131913
const CTxOut& prevoutput = coin.out;
19141914

19151915
tx_total_in += prevoutput.nValue;
1916-
size_t prevout_size = GetSerializeSize(prevoutput, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
1916+
size_t prevout_size = GetSerializeSize(prevoutput) + PER_UTXO_OVERHEAD;
19171917
utxo_size_inc -= prevout_size;
19181918
utxo_size_inc_actual -= prevout_size;
19191919
}

src/script/interpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion,
19341934
if ((control[0] & TAPROOT_LEAF_MASK) == TAPROOT_LEAF_TAPSCRIPT) {
19351935
// Tapscript (leaf version 0xc0)
19361936
exec_script = CScript(script.begin(), script.end());
1937-
execdata.m_validation_weight_left = ::GetSerializeSize(witness.stack, PROTOCOL_VERSION) + VALIDATION_WEIGHT_OFFSET;
1937+
execdata.m_validation_weight_left = ::GetSerializeSize(witness.stack) + VALIDATION_WEIGHT_OFFSET;
19381938
execdata.m_validation_weight_left_init = true;
19391939
return ExecuteWitnessScript(stack, exec_script, flags, SigVersion::TAPSCRIPT, checker, execdata, serror);
19401940
}

src/script/sign.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static bool SignTaproot(const SigningProvider& provider, const BaseSignatureCrea
379379
result_stack.emplace_back(std::begin(script), std::end(script)); // Push the script
380380
result_stack.push_back(*control_blocks.begin()); // Push the smallest control block
381381
if (smallest_result_stack.size() == 0 ||
382-
GetSerializeSize(result_stack, PROTOCOL_VERSION) < GetSerializeSize(smallest_result_stack, PROTOCOL_VERSION)) {
382+
GetSerializeSize(result_stack) < GetSerializeSize(smallest_result_stack)) {
383383
smallest_result_stack = std::move(result_stack);
384384
}
385385
}

src/serialize.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ inline void WriteCompactSize(SizeComputer &s, uint64_t nSize)
11211121
}
11221122

11231123
template <typename T>
1124-
size_t GetSerializeSize(const T& t, int nVersion = 0)
1124+
size_t GetSerializeSize(const T& t)
11251125
{
11261126
return (SizeComputer() << t).size();
11271127
}

src/test/flatfile_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(flatfile_open)
4040
"lost if a trusted third party is still required to prevent double-spending.");
4141

4242
size_t pos1 = 0;
43-
size_t pos2 = pos1 + GetSerializeSize(line1, CLIENT_VERSION);
43+
size_t pos2 = pos1 + GetSerializeSize(line1);
4444

4545
// Write first line to file.
4646
{

src/test/fuzz/miniscript.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ void TestNode(const MsCtx script_ctx, const NodeRef& node, FuzzedDataProvider& p
11211121
assert(mal_success);
11221122
assert(stack_nonmal == stack_mal);
11231123
// Compute witness size (excluding script push, control block, and witness count encoding).
1124-
const size_t wit_size = GetSerializeSize(stack_nonmal, PROTOCOL_VERSION) - GetSizeOfCompactSize(stack_nonmal.size());
1124+
const size_t wit_size = GetSerializeSize(stack_nonmal) - GetSizeOfCompactSize(stack_nonmal.size());
11251125
assert(wit_size <= *node->GetWitnessSize());
11261126

11271127
// Test non-malleable satisfaction.

0 commit comments

Comments
 (0)