mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
Drop minor GetSerializeSize template
Now that `GetType()` is not propagated, the benefits are not worth the code.
This commit is contained in:
parent
da74db0940
commit
893628be01
3 changed files with 6 additions and 12 deletions
|
@ -147,7 +147,7 @@ static constexpr uint8_t PSBT_SEPARATOR = 0x00;
|
||||||
template<typename Stream, typename... X>
|
template<typename Stream, typename... X>
|
||||||
void SerializeToVector(Stream& s, const X&... args)
|
void SerializeToVector(Stream& s, const X&... args)
|
||||||
{
|
{
|
||||||
WriteCompactSize(s, GetSerializeSizeMany(s, args...));
|
WriteCompactSize(s, GetSerializeSizeMany(s.GetVersion(), args...));
|
||||||
SerializeMany(s, args...);
|
SerializeMany(s, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -983,16 +983,10 @@ size_t GetSerializeSize(const T& t, int nVersion = 0)
|
||||||
return (CSizeComputer(nVersion) << t).size();
|
return (CSizeComputer(nVersion) << t).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename S, typename T>
|
template <typename... T>
|
||||||
size_t GetSerializeSize(const S& s, const T& t)
|
size_t GetSerializeSizeMany(int nVersion, const T&... t)
|
||||||
{
|
{
|
||||||
return (CSizeComputer(s.GetVersion()) << t).size();
|
CSizeComputer sc(nVersion);
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename... T>
|
|
||||||
size_t GetSerializeSizeMany(const S& s, const T&... t)
|
|
||||||
{
|
|
||||||
CSizeComputer sc(s.GetType(), s.GetVersion());
|
|
||||||
SerializeMany(sc, t...);
|
SerializeMany(sc, t...);
|
||||||
return sc.size();
|
return sc.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ static bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMes
|
||||||
return error("WriteBlockToDisk: OpenBlockFile failed");
|
return error("WriteBlockToDisk: OpenBlockFile failed");
|
||||||
|
|
||||||
// Write index header
|
// Write index header
|
||||||
unsigned int nSize = GetSerializeSize(fileout, block);
|
unsigned int nSize = GetSerializeSize(block, fileout.GetVersion());
|
||||||
fileout << messageStart << nSize;
|
fileout << messageStart << nSize;
|
||||||
|
|
||||||
// Write block
|
// Write block
|
||||||
|
@ -1470,7 +1470,7 @@ bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint
|
||||||
return error("%s: OpenUndoFile failed", __func__);
|
return error("%s: OpenUndoFile failed", __func__);
|
||||||
|
|
||||||
// Write index header
|
// Write index header
|
||||||
unsigned int nSize = GetSerializeSize(fileout, blockundo);
|
unsigned int nSize = GetSerializeSize(blockundo, fileout.GetVersion());
|
||||||
fileout << messageStart << nSize;
|
fileout << messageStart << nSize;
|
||||||
|
|
||||||
// Write undo data
|
// Write undo data
|
||||||
|
|
Loading…
Add table
Reference in a new issue