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 authored and furszy committed Jul 3, 2021
1 parent f05e692 commit ace7d14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -1134,15 +1134,17 @@ 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();
CSizeComputer sc(nVersion);
SerializeMany(sc, t...);
return sc.size();
}

/**
* optional
*/
* optional
*/
template<typename T>
unsigned int GetSerializeSize(const Optional<T> &item)
{
Expand Down
4 changes: 2 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos)
return error("WriteBlockToDisk : OpenBlockFile failed");

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

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

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

// Write undo data
Expand Down

0 comments on commit ace7d14

Please sign in to comment.