Skip to content

Commit

Permalink
Drop minor GetSerializeSize template
Browse files Browse the repository at this point in the history
Now that `GetType()` is not propagated, the benefits are not worth the code.
  • Loading branch information
Empact committed Sep 11, 2018
1 parent da74db0 commit 893628b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/script/sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static constexpr uint8_t PSBT_SEPARATOR = 0x00;
template<typename Stream, typename... X>
void SerializeToVector(Stream& s, const X&... args)
{
WriteCompactSize(s, GetSerializeSizeMany(s, args...));
WriteCompactSize(s, GetSerializeSizeMany(s.GetVersion(), args...));
SerializeMany(s, args...);
}

Expand Down
12 changes: 3 additions & 9 deletions src/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -983,16 +983,10 @@ size_t GetSerializeSize(const T& t, int nVersion = 0)
return (CSizeComputer(nVersion) << t).size();
}

template <typename S, typename T>
size_t GetSerializeSize(const S& s, const T& t)
template <typename... T>
size_t GetSerializeSizeMany(int nVersion, const T&... t)
{
return (CSizeComputer(s.GetVersion()) << t).size();
}

template <typename S, typename... T>
size_t GetSerializeSizeMany(const S& s, const T&... t)
{
CSizeComputer sc(s.GetType(), s.GetVersion());
CSizeComputer sc(nVersion);
SerializeMany(sc, t...);
return sc.size();
}
Expand Down
4 changes: 2 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ static bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMes
return error("WriteBlockToDisk: OpenBlockFile failed");

// Write index header
unsigned int nSize = GetSerializeSize(fileout, block);
unsigned int nSize = GetSerializeSize(block, fileout.GetVersion());
fileout << messageStart << nSize;

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

// Write index header
unsigned int nSize = GetSerializeSize(fileout, blockundo);
unsigned int nSize = GetSerializeSize(blockundo, fileout.GetVersion());
fileout << messageStart << nSize;

// Write undo data
Expand Down

0 comments on commit 893628b

Please sign in to comment.