diff --git a/src/blockencodings.h b/src/blockencodings.h --- a/src/blockencodings.h +++ b/src/blockencodings.h @@ -99,12 +99,12 @@ while (txn.size() < txn_size) { txn.resize(std::min(uint64_t(1000 + txn.size()), txn_size)); for (; i < txn.size(); i++) { - READWRITE(REF(TransactionCompressor(txn[i]))); + READWRITE(TransactionCompressor(txn[i])); } } } else { for (size_t i = 0; i < txn.size(); i++) { - READWRITE(REF(TransactionCompressor(txn[i]))); + READWRITE(TransactionCompressor(txn[i])); } } } @@ -128,7 +128,7 @@ throw std::ios_base::failure("index overflowed 32-bits"); } index = n; - READWRITE(REF(TransactionCompressor(tx))); + READWRITE(TransactionCompressor(tx)); } }; diff --git a/src/coins.h b/src/coins.h --- a/src/coins.h +++ b/src/coins.h @@ -61,7 +61,7 @@ template void Unserialize(Stream &s) { ::Unserialize(s, VARINT(nHeightAndIsCoinBase)); - ::Unserialize(s, REF(CTxOutCompressor(out))); + ::Unserialize(s, CTxOutCompressor(out)); } size_t DynamicMemoryUsage() const { diff --git a/src/compressor.h b/src/compressor.h --- a/src/compressor.h +++ b/src/compressor.h @@ -73,7 +73,7 @@ s >> VARINT(nSize); if (nSize < nSpecialScripts) { std::vector vch(GetSpecialSize(nSize), 0x00); - s >> REF(CFlatData(vch)); + s >> CFlatData(vch); Decompress(nSize, vch); return; } @@ -84,7 +84,7 @@ s.ignore(nSize); } else { script.resize(nSize); - s >> REF(CFlatData(script)); + s >> CFlatData(script); } } }; diff --git a/src/hash.h b/src/hash.h --- a/src/hash.h +++ b/src/hash.h @@ -191,7 +191,7 @@ } } - template CHashVerifier &operator>>(T &obj) { + template CHashVerifier &operator>>(T &&obj) { // Unserialize from this stream ::Unserialize(*this, obj); return (*this); diff --git a/src/script/bitcoinconsensus.cpp b/src/script/bitcoinconsensus.cpp --- a/src/script/bitcoinconsensus.cpp +++ b/src/script/bitcoinconsensus.cpp @@ -41,7 +41,7 @@ m_data += nSize; } - template TxInputStream &operator>>(T &obj) { + template TxInputStream &operator>>(T &&obj) { ::Unserialize(*this, obj); return *this; } diff --git a/src/serialize.h b/src/serialize.h --- a/src/serialize.h +++ b/src/serialize.h @@ -381,11 +381,10 @@ } } -#define FLATDATA(obj) \ - REF(CFlatData((char *)&(obj), (char *)&(obj) + sizeof(obj))) -#define VARINT(obj) REF(WrapVarInt(REF(obj))) -#define COMPACTSIZE(obj) REF(CCompactSize(REF(obj))) -#define LIMITED_STRING(obj, n) REF(LimitedString(REF(obj))) +#define FLATDATA(obj) CFlatData((char *)&(obj), (char *)&(obj) + sizeof(obj)) +#define VARINT(obj) WrapVarInt(REF(obj)) +#define COMPACTSIZE(obj) CCompactSize(REF(obj)) +#define LIMITED_STRING(obj, n) LimitedString(REF(obj)) /** * Wrapper for serializing arrays and POD. @@ -581,7 +580,7 @@ } template -inline void Unserialize(Stream &is, T &a) { +inline void Unserialize(Stream &is, T &&a) { a.Unserialize(is); } @@ -866,28 +865,28 @@ template void SerializeMany(Stream &s) {} template -void SerializeMany(Stream &s, Arg &&arg, Args &&... args) { - ::Serialize(s, std::forward(arg)); - ::SerializeMany(s, std::forward(args)...); +void SerializeMany(Stream &s, const Arg &arg, const Args &... args) { + ::Serialize(s, arg); + ::SerializeMany(s, args...); } template inline void UnserializeMany(Stream &s) {} template -inline void UnserializeMany(Stream &s, Arg &arg, Args &... args) { +inline void UnserializeMany(Stream &s, Arg &&arg, Args &&... args) { ::Unserialize(s, arg); ::UnserializeMany(s, args...); } template inline void SerReadWriteMany(Stream &s, CSerActionSerialize ser_action, - Args &&... args) { - ::SerializeMany(s, std::forward(args)...); + const Args &... args) { + ::SerializeMany(s, args...); } template inline void SerReadWriteMany(Stream &s, CSerActionUnserialize ser_action, - Args &... args) { + Args &&... args) { ::UnserializeMany(s, args...); } diff --git a/src/streams.h b/src/streams.h --- a/src/streams.h +++ b/src/streams.h @@ -38,7 +38,7 @@ return (*this); } - template OverrideStream &operator>>(T &obj) { + template OverrideStream &operator>>(T &&obj) { // Unserialize from this stream ::Unserialize(*this, obj); return (*this); @@ -434,7 +434,7 @@ return (*this); } - template CDataStream &operator>>(T &obj) { + template CDataStream &operator>>(T &&obj) { // Unserialize from this stream ::Unserialize(*this, obj); return (*this); @@ -666,7 +666,7 @@ return (*this); } - template CAutoFile &operator>>(T &obj) { + template CAutoFile &operator>>(T &&obj) { // Unserialize from this stream if (!file) throw std::ios_base::failure( @@ -801,7 +801,7 @@ return true; } - template CBufferedFile &operator>>(T &obj) { + template CBufferedFile &operator>>(T &&obj) { // Unserialize from this stream ::Unserialize(*this, obj); return (*this); diff --git a/src/txdb.cpp b/src/txdb.cpp --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -368,7 +368,7 @@ vout.assign(vAvail.size(), CTxOut()); for (size_t i = 0; i < vAvail.size(); i++) { if (vAvail[i]) { - ::Unserialize(s, REF(CTxOutCompressor(vout[i]))); + ::Unserialize(s, CTxOutCompressor(vout[i])); } } // coinbase height diff --git a/src/undo.h b/src/undo.h --- a/src/undo.h +++ b/src/undo.h @@ -63,7 +63,7 @@ } CTxOut txout; - ::Unserialize(s, REF(CTxOutCompressor(REF(txout)))); + ::Unserialize(s, CTxOutCompressor(REF(txout))); *pcoin = Coin(std::move(txout), nHeight, fCoinBase); } @@ -83,7 +83,7 @@ uint64_t count = vprevout.size(); ::Serialize(s, COMPACTSIZE(REF(count))); for (const auto &prevout : vprevout) { - ::Serialize(s, REF(TxInUndoSerializer(&prevout))); + ::Serialize(s, TxInUndoSerializer(&prevout)); } } @@ -96,7 +96,7 @@ } vprevout.resize(count); for (auto &prevout : vprevout) { - ::Unserialize(s, REF(TxInUndoDeserializer(&prevout))); + ::Unserialize(s, TxInUndoDeserializer(&prevout)); } } };