mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Get rid of nType and nVersion
Remove the nType and nVersion as parameters to all serialization methods and functions. There is only one place where it's read and has an impact (in CAddress), and even there it does not impact any of the recursively invoked serializers. Instead, the few places that need nType or nVersion are changed to read it directly from the stream object, through GetType() and GetVersion() methods which are added to all stream classes.
This commit is contained in:
20
src/undo.h
20
src/undo.h
@@ -28,22 +28,22 @@ public:
|
||||
CTxInUndo(const CTxOut &txoutIn, bool fCoinBaseIn = false, unsigned int nHeightIn = 0, int nVersionIn = 0) : txout(txoutIn), fCoinBase(fCoinBaseIn), nHeight(nHeightIn), nVersion(nVersionIn) { }
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream &s, int nType, int nVersion) const {
|
||||
::Serialize(s, VARINT(nHeight*2+(fCoinBase ? 1 : 0)), nType, nVersion);
|
||||
void Serialize(Stream &s) const {
|
||||
::Serialize(s, VARINT(nHeight*2+(fCoinBase ? 1 : 0)));
|
||||
if (nHeight > 0)
|
||||
::Serialize(s, VARINT(this->nVersion), nType, nVersion);
|
||||
::Serialize(s, CTxOutCompressor(REF(txout)), nType, nVersion);
|
||||
::Serialize(s, VARINT(this->nVersion));
|
||||
::Serialize(s, CTxOutCompressor(REF(txout)));
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream &s, int nType, int nVersion) {
|
||||
void Unserialize(Stream &s) {
|
||||
unsigned int nCode = 0;
|
||||
::Unserialize(s, VARINT(nCode), nType, nVersion);
|
||||
::Unserialize(s, VARINT(nCode));
|
||||
nHeight = nCode / 2;
|
||||
fCoinBase = nCode & 1;
|
||||
if (nHeight > 0)
|
||||
::Unserialize(s, VARINT(this->nVersion), nType, nVersion);
|
||||
::Unserialize(s, REF(CTxOutCompressor(REF(txout))), nType, nVersion);
|
||||
::Unserialize(s, VARINT(this->nVersion));
|
||||
::Unserialize(s, REF(CTxOutCompressor(REF(txout))));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||
READWRITE(vprevout);
|
||||
}
|
||||
};
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||
READWRITE(vtxundo);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user