diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp index b4ff0ee3373f..47482e9c8ff1 100644 --- a/src/bench/checkblock.cpp +++ b/src/bench/checkblock.cpp @@ -17,7 +17,7 @@ static void DeserializeBlockTest(benchmark::Bench& bench) { - CDataStream stream(benchmark::data::block813851, SER_NETWORK, PROTOCOL_VERSION); + DataStream stream(benchmark::data::block813851); std::byte a{0}; stream.write({&a, 1}); // Prevent compaction @@ -31,7 +31,7 @@ static void DeserializeBlockTest(benchmark::Bench& bench) static void DeserializeAndCheckBlockTest(benchmark::Bench& bench) { - CDataStream stream(benchmark::data::block813851, SER_NETWORK, PROTOCOL_VERSION); + DataStream stream(benchmark::data::block813851); std::byte a{0}; stream.write({&a, 1}); // Prevent compaction diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp index b66c98e8e80c..9f1757322066 100644 --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -164,7 +164,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c break; } - LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock, PROTOCOL_VERSION)); + LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock)); return READ_STATUS_OK; } diff --git a/src/coins.cpp b/src/coins.cpp index 0aa3bf708484..6e37bd390e50 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -8,7 +8,6 @@ #include #include #include -#include bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return false; } uint256 CCoinsView::GetBestBlock() const { return uint256(); } @@ -339,7 +338,7 @@ void CCoinsViewCache::SanityCheck() const assert(recomputed_usage == cachedCoinsUsage); } -static const size_t MAX_OUTPUTS_PER_BLOCK = MaxBlockSize() / ::GetSerializeSize(CTxOut(), PROTOCOL_VERSION); +static const size_t MAX_OUTPUTS_PER_BLOCK = MaxBlockSize() / ::GetSerializeSize(CTxOut()); const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid) { diff --git a/src/core_read.cpp b/src/core_read.cpp index 9f7c198d3f9e..86d8f6091d39 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/src/hash.h b/src/hash.h index 5dad7c72bcf7..a2ace4c9040e 100644 --- a/src/hash.h +++ b/src/hash.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp index f21b8afe4b43..33848d909a60 100644 --- a/src/index/blockfilterindex.cpp +++ b/src/index/blockfilterindex.cpp @@ -176,8 +176,8 @@ size_t BlockFilterIndex::WriteFilterToDisk(FlatFilePos& pos, const BlockFilter& assert(filter.GetFilterType() == GetFilterType()); size_t data_size = - GetSerializeSize(filter.GetBlockHash(), CLIENT_VERSION) + - GetSerializeSize(filter.GetEncodedFilter(), CLIENT_VERSION); + GetSerializeSize(filter.GetBlockHash()) + + GetSerializeSize(filter.GetEncodedFilter()); // If writing the filter would overflow the file, flush and move to the next one. if (pos.nPos + data_size > MAX_FLTR_FILE_SIZE) { diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 0a5ca022fa73..d8dbed4bc9a6 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -493,7 +493,7 @@ static bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const } // Write index header - unsigned int nSize = GetSerializeSize(blockundo, fileout.GetVersion()); + unsigned int nSize = GetSerializeSize(blockundo); fileout << messageStart << nSize; // Write undo data @@ -719,7 +719,7 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid // Write undo information to disk if (pindex->GetUndoPos().IsNull()) { FlatFilePos _pos; - if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, CLIENT_VERSION) + 40)) { + if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo) + 40)) { return error("ConnectBlock(): FindUndoPos failed"); } if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart())) { diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index a56f8c3677f4..3c7c4592fc20 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/src/psbt.cpp b/src/psbt.cpp index 90285c414ee8..c707e2d79ec8 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include diff --git a/src/psbt.h b/src/psbt.h index d3d778d8952a..8c2ef582baa7 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -77,7 +77,9 @@ struct PSBTProprietary template void SerializeToVector(Stream& s, const X&... args) { - WriteCompactSize(s, GetSerializeSizeMany(s.GetVersion(), args...)); + SizeComputer sizecomp; + SerializeMany(sizecomp, args...); + WriteCompactSize(s, sizecomp.size()); SerializeMany(s, args...); } diff --git a/src/rest.cpp b/src/rest.cpp index e58a650689f6..b10fb6c8aefb 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 084849d6a8bd..b46834e772bc 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2085,7 +2085,7 @@ static RPCHelpMan getblockstats() for (const CTxOut& out : tx->vout) { tx_total_out += out.nValue; - size_t out_size = GetSerializeSize(out, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD; + size_t out_size = GetSerializeSize(out) + PER_UTXO_OVERHEAD; utxo_size_inc += out_size; // The Genesis block and the repeated BIP30 block coinbases don't change the UTXO @@ -2125,7 +2125,7 @@ static RPCHelpMan getblockstats() const CTxOut& prevoutput = coin.out; tx_total_in += prevoutput.nValue; - size_t prevout_size = GetSerializeSize(prevoutput, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD; + size_t prevout_size = GetSerializeSize(prevoutput) + PER_UTXO_OVERHEAD; utxo_size_inc -= prevout_size; utxo_size_inc_actual -= prevout_size; } diff --git a/src/script/bitcoinconsensus.cpp b/src/script/bitcoinconsensus.cpp index 8f979a0c26b0..7efea1f853ca 100644 --- a/src/script/bitcoinconsensus.cpp +++ b/src/script/bitcoinconsensus.cpp @@ -8,7 +8,6 @@ #include #include #include