aboutsummaryrefslogtreecommitdiff
path: root/src/undo.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-04-25 11:29:18 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-05-26 13:27:50 -0700
commitd342424301013ec47dc146a4beb49d5c9319d80a (patch)
tree00574e5165c4b96167009fefe525b024e98eae0f /src/undo.h
parent7e0032290669fae5f52c256856c53038511c7db4 (diff)
Remove/ignore tx version in utxo and undo
This makes the following changes: * In undo data and the chainstate database, the transaction nVersion field is removed from the data structures, always written as 0, and ignored when reading. * The definition of hash_serialized in gettxoutsetinfo is changed to no longer incude the nVersion field. It is renamed to hash_serialized_2 to avoid confusion. The new definition also includes transaction height and coinbase information, as this information was missing before. This depends on having a CHashVerifier-based undo data checksum verifier. Apart from changing the definition of serialized_hash, downgrading after using this patch is supported, as no release ever used the value of nVersion field in UTXO entries.
Diffstat (limited to 'src/undo.h')
-rw-r--r--src/undo.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/undo.h b/src/undo.h
index a94e31f5cc..d21b82e2ec 100644
--- a/src/undo.h
+++ b/src/undo.h
@@ -14,7 +14,8 @@
*
* Contains the prevout's CTxOut being spent, and if this was the
* last output of the affected transaction, its metadata as well
- * (coinbase or not, height, transaction version)
+ * (coinbase or not, height). Earlier versions also stored the transaction
+ * version.
*/
class CTxInUndo
{
@@ -22,16 +23,17 @@ public:
CTxOut txout; // the txout data before being spent
bool fCoinBase; // if the outpoint was the last unspent: whether it belonged to a coinbase
unsigned int nHeight; // if the outpoint was the last unspent: its height
- int nVersion; // if the outpoint was the last unspent: its version
- CTxInUndo() : txout(), fCoinBase(false), nHeight(0), nVersion(0) {}
- CTxInUndo(const CTxOut &txoutIn, bool fCoinBaseIn = false, unsigned int nHeightIn = 0, int nVersionIn = 0) : txout(txoutIn), fCoinBase(fCoinBaseIn), nHeight(nHeightIn), nVersion(nVersionIn) { }
+ CTxInUndo() : txout(), fCoinBase(false), nHeight(0) {}
+ CTxInUndo(const CTxOut &txoutIn, bool fCoinBaseIn = false, unsigned int nHeightIn = 0) : txout(txoutIn), fCoinBase(fCoinBaseIn), nHeight(nHeightIn) { }
template<typename Stream>
void Serialize(Stream &s) const {
::Serialize(s, VARINT(nHeight*2+(fCoinBase ? 1 : 0)));
- if (nHeight > 0)
- ::Serialize(s, VARINT(this->nVersion));
+ if (nHeight > 0) {
+ int nVersionDummy = 0;
+ ::Serialize(s, VARINT(nVersionDummy));
+ }
::Serialize(s, CTxOutCompressor(REF(txout)));
}
@@ -41,8 +43,10 @@ public:
::Unserialize(s, VARINT(nCode));
nHeight = nCode / 2;
fCoinBase = nCode & 1;
- if (nHeight > 0)
- ::Unserialize(s, VARINT(this->nVersion));
+ if (nHeight > 0) {
+ int nVersionDummy;
+ ::Unserialize(s, VARINT(nVersionDummy));
+ }
::Unserialize(s, REF(CTxOutCompressor(REF(txout))));
}
};