From 68a1a592ca479146e6c228ef76471e7d4a8ad94e Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 15 Apr 2018 21:09:19 -0600 Subject: [PATCH] Remove nType and nVersion from Zcash-specific code --- src/alert.h | 4 +-- src/chain.h | 2 +- src/hash.h | 2 +- src/paymentdisclosure.h | 6 ++--- src/primitives/block.h | 3 +-- src/primitives/transaction.h | 4 +-- src/script/interpreter.cpp | 6 ++--- src/serialize.h | 42 ++++++++++++++--------------- src/uint252.h | 2 +- src/wallet/wallet.h | 4 +-- src/zcash/Address.hpp | 4 +-- src/zcash/IncrementalMerkleTree.hpp | 6 ++--- src/zcash/Note.hpp | 2 +- src/zcash/Proof.hpp | 10 +++---- 14 files changed, 47 insertions(+), 50 deletions(-) diff --git a/src/alert.h b/src/alert.h index 76d8d916e..bf29e854c 100644 --- a/src/alert.h +++ b/src/alert.h @@ -49,7 +49,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(this->nVersion); nVersion = this->nVersion; READWRITE(nRelayUntil); @@ -87,7 +87,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(vchMsg); READWRITE(vchSig); } diff --git a/src/chain.h b/src/chain.h index 793ef4f03..906267326 100644 --- a/src/chain.h +++ b/src/chain.h @@ -380,7 +380,7 @@ public: // Only read/write nSproutValue if the client version used to create // this index was storing them. - if ((nType & SER_DISK) && (nVersion >= SPROUT_VALUE_VERSION)) { + if ((s.GetType() & SER_DISK) && (nVersion >= SPROUT_VALUE_VERSION)) { READWRITE(nSproutValue); } } diff --git a/src/hash.h b/src/hash.h index 8276c9184..76634bd37 100644 --- a/src/hash.h +++ b/src/hash.h @@ -197,7 +197,7 @@ public: template CBLAKE2bWriter& operator<<(const T& obj) { // Serialize to this stream - ::Serialize(*this, obj, nType, nVersion); + ::Serialize(*this, obj); return (*this); } }; diff --git a/src/paymentdisclosure.h b/src/paymentdisclosure.h index c5d29d5c6..b3681affc 100644 --- a/src/paymentdisclosure.h +++ b/src/paymentdisclosure.h @@ -48,7 +48,7 @@ struct PaymentDisclosureInfo { ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(version); READWRITE(esk); READWRITE(joinSplitPrivKey); @@ -81,7 +81,7 @@ struct PaymentDisclosurePayload { ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(marker); READWRITE(version); READWRITE(esk); @@ -123,7 +123,7 @@ struct PaymentDisclosure { ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(payload); READWRITE(payloadSig); } diff --git a/src/primitives/block.h b/src/primitives/block.h index 7fe1a3588..1d8750588 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -155,9 +155,8 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(this->nVersion); - nVersion = this->nVersion; READWRITE(hashPrevBlock); READWRITE(hashMerkleRoot); READWRITE(hashReserved); diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 60ea11239..7a4a315e2 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -109,7 +109,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(vpub_old); READWRITE(vpub_new); READWRITE(anchor); @@ -383,7 +383,6 @@ public: uint32_t header = GetHeader(); READWRITE(header); } - nVersion = this->nVersion; if (fOverwintered) { READWRITE(*const_cast(&this->nVersionGroupId)); } @@ -498,7 +497,6 @@ struct CMutableTransaction } READWRITE(header); } - nVersion = this->nVersion; if (fOverwintered) { READWRITE(nVersionGroupId); } diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index f262faef9..e405b42f3 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1046,12 +1046,12 @@ public: // keeps the JoinSplit cryptographically bound // to the transaction. // - ::Serialize(s, txTo.vjoinsplit, nType, nVersion); + ::Serialize(s, txTo.vjoinsplit); if (txTo.vjoinsplit.size() > 0) { - ::Serialize(s, txTo.joinSplitPubKey, nType, nVersion); + ::Serialize(s, txTo.joinSplitPubKey); CTransaction::joinsplit_sig_t nullSig = {}; - ::Serialize(s, nullSig, nType, nVersion); + ::Serialize(s, nullSig); } } } diff --git a/src/serialize.h b/src/serialize.h index 0cc5216fd..2bb80f822 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -503,14 +503,14 @@ template inline void Unserialize(Stream /** * optional */ -template void Serialize(Stream& os, const boost::optional& item, int nType, int nVersion); -template void Unserialize(Stream& is, boost::optional& item, int nType, int nVersion); +template void Serialize(Stream& os, const boost::optional& item); +template void Unserialize(Stream& is, boost::optional& item); /** * array */ -template void Serialize(Stream& os, const boost::array& item, int nType, int nVersion); -template void Unserialize(Stream& is, boost::array& item, int nType, int nVersion); +template void Serialize(Stream& os, const boost::array& item); +template void Unserialize(Stream& is, boost::array& item); /** * pair @@ -533,8 +533,8 @@ template void Unserializ /** * list */ -template void Serialize(Stream& os, const std::list& m, int nType, int nVersion); -template void Unserialize(Stream& is, std::list& m, int nType, int nVersion); +template void Serialize(Stream& os, const std::list& m); +template void Unserialize(Stream& is, std::list& m); @@ -721,31 +721,31 @@ inline void Unserialize(Stream& is, std::vector& v) * optional */ template -void Serialize(Stream& os, const boost::optional& item, int nType, int nVersion) +void Serialize(Stream& os, const boost::optional& item) { // If the value is there, put 0x01 and then serialize the value. // If it's not, put 0x00. if (item) { unsigned char discriminant = 0x01; - Serialize(os, discriminant, nType, nVersion); - Serialize(os, *item, nType, nVersion); + Serialize(os, discriminant); + Serialize(os, *item); } else { unsigned char discriminant = 0x00; - Serialize(os, discriminant, nType, nVersion); + Serialize(os, discriminant); } } template -void Unserialize(Stream& is, boost::optional& item, int nType, int nVersion) +void Unserialize(Stream& is, boost::optional& item) { unsigned char discriminant = 0x00; - Unserialize(is, discriminant, nType, nVersion); + Unserialize(is, discriminant); if (discriminant == 0x00) { item = boost::none; } else if (discriminant == 0x01) { T object; - Unserialize(is, object, nType, nVersion); + Unserialize(is, object); item = object; } else { throw std::ios_base::failure("non-canonical optional discriminant"); @@ -758,18 +758,18 @@ void Unserialize(Stream& is, boost::optional& item, int nType, int nVersion) * array */ template -void Serialize(Stream& os, const boost::array& item, int nType, int nVersion) +void Serialize(Stream& os, const boost::array& item) { for (size_t i = 0; i < N; i++) { - Serialize(os, item[i], nType, nVersion); + Serialize(os, item[i]); } } template -void Unserialize(Stream& is, boost::array& item, int nType, int nVersion) +void Unserialize(Stream& is, boost::array& item) { for (size_t i = 0; i < N; i++) { - Unserialize(is, item[i], nType, nVersion); + Unserialize(is, item[i]); } } @@ -851,15 +851,15 @@ void Unserialize(Stream& is, std::set& m) * list */ template -void Serialize(Stream& os, const std::list& l, int nType, int nVersion) +void Serialize(Stream& os, const std::list& l) { WriteCompactSize(os, l.size()); for (typename std::list::const_iterator it = l.begin(); it != l.end(); ++it) - Serialize(os, (*it), nType, nVersion); + Serialize(os, (*it)); } template -void Unserialize(Stream& is, std::list& l, int nType, int nVersion) +void Unserialize(Stream& is, std::list& l) { l.clear(); unsigned int nSize = ReadCompactSize(is); @@ -867,7 +867,7 @@ void Unserialize(Stream& is, std::list& l, int nType, int nVersion) for (unsigned int i = 0; i < nSize; i++) { T item; - Unserialize(is, item, nType, nVersion); + Unserialize(is, item); l.push_back(item); } } diff --git a/src/uint252.h b/src/uint252.h index 6281e8533..e7b98ddf0 100644 --- a/src/uint252.h +++ b/src/uint252.h @@ -15,7 +15,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(contents); if ((*contents.begin()) & 0xF0) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 5a16cb290..6c968fca9 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -170,7 +170,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(hash); READWRITE(js); READWRITE(n); @@ -241,7 +241,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(address); READWRITE(nullifier); READWRITE(witnesses); diff --git a/src/zcash/Address.hpp b/src/zcash/Address.hpp index 2dbe10a60..c165c20dd 100644 --- a/src/zcash/Address.hpp +++ b/src/zcash/Address.hpp @@ -22,7 +22,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(a_pk); READWRITE(pk_enc); } @@ -58,7 +58,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(a_pk); READWRITE(sk_enc); } diff --git a/src/zcash/IncrementalMerkleTree.hpp b/src/zcash/IncrementalMerkleTree.hpp index fd7c61518..c4cf9d675 100644 --- a/src/zcash/IncrementalMerkleTree.hpp +++ b/src/zcash/IncrementalMerkleTree.hpp @@ -21,7 +21,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { std::vector> pathBytes; uint64_t indexInt; if (ser_action.ForRead()) { @@ -112,7 +112,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(left); READWRITE(right); READWRITE(parents); @@ -178,7 +178,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(tree); READWRITE(filled); READWRITE(cursor); diff --git a/src/zcash/Note.hpp b/src/zcash/Note.hpp index faacd2720..9b2676931 100644 --- a/src/zcash/Note.hpp +++ b/src/zcash/Note.hpp @@ -40,7 +40,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { unsigned char leadingByte = 0x00; READWRITE(leadingByte); diff --git a/src/zcash/Proof.hpp b/src/zcash/Proof.hpp index 5f05aa2c5..573a65cd3 100644 --- a/src/zcash/Proof.hpp +++ b/src/zcash/Proof.hpp @@ -25,7 +25,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(data); } @@ -58,7 +58,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(data); } @@ -93,7 +93,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { unsigned char leadingByte = G1_PREFIX_MASK; if (y_lsb) { @@ -143,7 +143,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { unsigned char leadingByte = G2_PREFIX_MASK; if (y_gt) { @@ -204,7 +204,7 @@ public: ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(g_A); READWRITE(g_A_prime); READWRITE(g_B);