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:
parent
657e05ab2e
commit
528472111b
36 changed files with 304 additions and 280 deletions
src/script
|
@ -1069,7 +1069,7 @@ public:
|
|||
|
||||
/** Serialize the passed scriptCode, skipping OP_CODESEPARATORs */
|
||||
template<typename S>
|
||||
void SerializeScriptCode(S &s, int nType, int nVersion) const {
|
||||
void SerializeScriptCode(S &s) const {
|
||||
CScript::const_iterator it = scriptCode.begin();
|
||||
CScript::const_iterator itBegin = it;
|
||||
opcodetype opcode;
|
||||
|
@ -1092,53 +1092,53 @@ public:
|
|||
|
||||
/** Serialize an input of txTo */
|
||||
template<typename S>
|
||||
void SerializeInput(S &s, unsigned int nInput, int nType, int nVersion) const {
|
||||
void SerializeInput(S &s, unsigned int nInput) const {
|
||||
// In case of SIGHASH_ANYONECANPAY, only the input being signed is serialized
|
||||
if (fAnyoneCanPay)
|
||||
nInput = nIn;
|
||||
// Serialize the prevout
|
||||
::Serialize(s, txTo.vin[nInput].prevout, nType, nVersion);
|
||||
::Serialize(s, txTo.vin[nInput].prevout);
|
||||
// Serialize the script
|
||||
if (nInput != nIn)
|
||||
// Blank out other inputs' signatures
|
||||
::Serialize(s, CScriptBase(), nType, nVersion);
|
||||
::Serialize(s, CScriptBase());
|
||||
else
|
||||
SerializeScriptCode(s, nType, nVersion);
|
||||
SerializeScriptCode(s);
|
||||
// Serialize the nSequence
|
||||
if (nInput != nIn && (fHashSingle || fHashNone))
|
||||
// let the others update at will
|
||||
::Serialize(s, (int)0, nType, nVersion);
|
||||
::Serialize(s, (int)0);
|
||||
else
|
||||
::Serialize(s, txTo.vin[nInput].nSequence, nType, nVersion);
|
||||
::Serialize(s, txTo.vin[nInput].nSequence);
|
||||
}
|
||||
|
||||
/** Serialize an output of txTo */
|
||||
template<typename S>
|
||||
void SerializeOutput(S &s, unsigned int nOutput, int nType, int nVersion) const {
|
||||
void SerializeOutput(S &s, unsigned int nOutput) const {
|
||||
if (fHashSingle && nOutput != nIn)
|
||||
// Do not lock-in the txout payee at other indices as txin
|
||||
::Serialize(s, CTxOut(), nType, nVersion);
|
||||
::Serialize(s, CTxOut());
|
||||
else
|
||||
::Serialize(s, txTo.vout[nOutput], nType, nVersion);
|
||||
::Serialize(s, txTo.vout[nOutput]);
|
||||
}
|
||||
|
||||
/** Serialize txTo */
|
||||
template<typename S>
|
||||
void Serialize(S &s, int nType, int nVersion) const {
|
||||
void Serialize(S &s) const {
|
||||
// Serialize nVersion
|
||||
::Serialize(s, txTo.nVersion, nType, nVersion);
|
||||
::Serialize(s, txTo.nVersion);
|
||||
// Serialize vin
|
||||
unsigned int nInputs = fAnyoneCanPay ? 1 : txTo.vin.size();
|
||||
::WriteCompactSize(s, nInputs);
|
||||
for (unsigned int nInput = 0; nInput < nInputs; nInput++)
|
||||
SerializeInput(s, nInput, nType, nVersion);
|
||||
SerializeInput(s, nInput);
|
||||
// Serialize vout
|
||||
unsigned int nOutputs = fHashNone ? 0 : (fHashSingle ? nIn+1 : txTo.vout.size());
|
||||
::WriteCompactSize(s, nOutputs);
|
||||
for (unsigned int nOutput = 0; nOutput < nOutputs; nOutput++)
|
||||
SerializeOutput(s, nOutput, nType, nVersion);
|
||||
SerializeOutput(s, nOutput);
|
||||
// Serialize nLockTime
|
||||
::Serialize(s, txTo.nLockTime, nType, nVersion);
|
||||
::Serialize(s, txTo.nLockTime);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue