diff --git a/src/chain.h b/src/chain.h index bb2763a1b1..5962f335f4 100644 --- a/src/chain.h +++ b/src/chain.h @@ -85,12 +85,9 @@ struct CDiskBlockPos int nFile; unsigned int nPos; - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(VARINT(nFile, VarIntMode::NONNEGATIVE_SIGNED)); - READWRITE(VARINT(nPos)); + SERIALIZE_METHODS(CDiskBlockPos, obj) + { + READWRITE(VARINT(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED), VARINT(obj.nPos)); } CDiskBlockPos() { diff --git a/src/streams.h b/src/streams.h index b7c3cbf21c..2505f07390 100644 --- a/src/streams.h +++ b/src/streams.h @@ -42,7 +42,7 @@ public: } template - OverrideStream& operator>>(T& obj) + OverrideStream& operator>>(T&& obj) { // Unserialize from this stream ::Unserialize(*this, obj); diff --git a/src/txdb.h b/src/txdb.h index 34f293e7b7..59fe68f242 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -46,12 +46,10 @@ struct CDiskTxPos : public CDiskBlockPos { unsigned int nTxOffset; // after header - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITEAS(CDiskBlockPos, *this); - READWRITE(VARINT(nTxOffset)); + SERIALIZE_METHODS(CDiskTxPos, obj) + { + READWRITEAS(CDiskBlockPos, obj); + READWRITE(VARINT(obj.nTxOffset)); } CDiskTxPos(const CDiskBlockPos &blockIn, unsigned int nTxOffsetIn) : CDiskBlockPos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) { diff --git a/src/undo.h b/src/undo.h index 3fd3ebc1bc..636f748867 100644 --- a/src/undo.h +++ b/src/undo.h @@ -28,7 +28,7 @@ struct TxInUndoFormatter // Required to maintain compatibility with older undo format. ::Serialize(s, (unsigned char)0); } - ::Serialize(s, Using(REF(txout.out))); + ::Serialize(s, Using(txout.out)); } template @@ -44,7 +44,7 @@ struct TxInUndoFormatter unsigned int nVersionDummy; ::Unserialize(s, VARINT(nVersionDummy)); } - ::Unserialize(s, Using(REF(txout.out))); + ::Unserialize(s, Using(txout.out)); } }; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 52a330b45c..8b9b2f1857 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -236,15 +236,10 @@ public: tx = std::move(arg); } - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { + SERIALIZE_METHODS(CMerkleTx, obj) + { std::vector vMerkleBranch; // For compatibility with older versions. - READWRITE(tx); - READWRITE(hashBlock); - READWRITE(vMerkleBranch); - READWRITE(nIndex); + READWRITE(obj.tx, obj.hashBlock, vMerkleBranch, obj.nIndex); } void SetMerkleBranch(const CBlockIndex* pIndex, int posInBlock); @@ -581,17 +576,12 @@ public: explicit CWalletKey(int64_t nExpires=0); - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { + SERIALIZE_METHODS(CWalletKey, obj) + { int nVersion = s.GetVersion(); if (!(s.GetType() & SER_GETHASH)) READWRITE(nVersion); - READWRITE(vchPrivKey); - READWRITE(nTimeCreated); - READWRITE(nTimeExpires); - READWRITE(LIMITED_STRING(strComment, 65536)); + READWRITE(obj.vchPrivKey, obj.nTimeCreated, obj.nTimeExpires, LIMITED_STRING(obj.strComment, 65536)); } }; @@ -1320,14 +1310,12 @@ public: vchPubKey = CPubKey(); } - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { + SERIALIZE_METHODS(CAccount, obj) + { int nVersion = s.GetVersion(); if (!(s.GetType() & SER_GETHASH)) READWRITE(nVersion); - READWRITE(vchPubKey); + READWRITE(obj.vchPubKey); } };