Merge pull request #2982 from gmaxwell/20130908_ccoins_corrupt

Longer term workaround for chainstate corruption from negative versions.
pull/2979/merge
Gregory Maxwell 11 years ago
commit 85311c1ef8

@ -466,7 +466,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans)
bool IsStandardTx(const CTransaction& tx, string& reason) bool IsStandardTx(const CTransaction& tx, string& reason)
{ {
if (tx.nVersion > CTransaction::CURRENT_VERSION) { if (tx.nVersion > CTransaction::CURRENT_VERSION || tx.nVersion < 1) {
reason = "version"; reason = "version";
return false; return false;
} }
@ -1778,6 +1778,11 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
CCoins &outs = view.GetCoins(hash); CCoins &outs = view.GetCoins(hash);
CCoins outsBlock = CCoins(tx, pindex->nHeight); CCoins outsBlock = CCoins(tx, pindex->nHeight);
// The CCoins serialization does not serialize negative numbers.
// No network rules currently depend on the version here, so an inconsistency is harmless
// but it must be corrected before txout nversion ever influences a network rule.
if (outsBlock.nVersion < 0)
outs.nVersion = outsBlock.nVersion;
if (outs != outsBlock) if (outs != outsBlock)
fClean = fClean && error("DisconnectBlock() : added transaction mismatch? database corrupted"); fClean = fClean && error("DisconnectBlock() : added transaction mismatch? database corrupted");

Loading…
Cancel
Save