Skip to content

Commit 893628b

Browse files
committed
Drop minor GetSerializeSize template
Now that `GetType()` is not propagated, the benefits are not worth the code.
1 parent da74db0 commit 893628b

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/script/sign.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static constexpr uint8_t PSBT_SEPARATOR = 0x00;
147147
template<typename Stream, typename... X>
148148
void SerializeToVector(Stream& s, const X&... args)
149149
{
150-
WriteCompactSize(s, GetSerializeSizeMany(s, args...));
150+
WriteCompactSize(s, GetSerializeSizeMany(s.GetVersion(), args...));
151151
SerializeMany(s, args...);
152152
}
153153

src/serialize.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -983,16 +983,10 @@ size_t GetSerializeSize(const T& t, int nVersion = 0)
983983
return (CSizeComputer(nVersion) << t).size();
984984
}
985985

986-
template <typename S, typename T>
987-
size_t GetSerializeSize(const S& s, const T& t)
986+
template <typename... T>
987+
size_t GetSerializeSizeMany(int nVersion, const T&... t)
988988
{
989-
return (CSizeComputer(s.GetVersion()) << t).size();
990-
}
991-
992-
template <typename S, typename... T>
993-
size_t GetSerializeSizeMany(const S& s, const T&... t)
994-
{
995-
CSizeComputer sc(s.GetType(), s.GetVersion());
989+
CSizeComputer sc(nVersion);
996990
SerializeMany(sc, t...);
997991
return sc.size();
998992
}

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ static bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMes
10601060
return error("WriteBlockToDisk: OpenBlockFile failed");
10611061

10621062
// Write index header
1063-
unsigned int nSize = GetSerializeSize(fileout, block);
1063+
unsigned int nSize = GetSerializeSize(block, fileout.GetVersion());
10641064
fileout << messageStart << nSize;
10651065

10661066
// Write block
@@ -1470,7 +1470,7 @@ bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint
14701470
return error("%s: OpenUndoFile failed", __func__);
14711471

14721472
// Write index header
1473-
unsigned int nSize = GetSerializeSize(fileout, blockundo);
1473+
unsigned int nSize = GetSerializeSize(blockundo, fileout.GetVersion());
14741474
fileout << messageStart << nSize;
14751475

14761476
// Write undo data

0 commit comments

Comments
 (0)