Mercurial > hg > bitcoin
changeset 3259:a976ed876e20 draft
Handle should-never-happen case of orphan in mempool
author | Gavin Andresen <gavinandresen@gmail.com> |
---|---|
date | Thu, 26 Jul 2012 15:29:59 -0400 (2012-07-26) |
parents | 79645c819457 |
children | c91c53a5d52d |
files | src/main.cpp |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.cpp +++ b/src/main.cpp @@ -3425,6 +3425,7 @@ COrphan* porphan = NULL; double dPriority = 0; int64 nTotalIn = 0; + bool fMissingInputs = false; BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -3432,6 +3433,19 @@ CTxIndex txindex; if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex)) { + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) + { + printf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; + } + // Has to wait for dependencies if (!porphan) { @@ -3450,6 +3464,7 @@ int nConf = txindex.GetDepthInMainChain(); dPriority += (double)nValueIn * nConf; } + if (fMissingInputs) continue; // Priority is sum(valuein * age) / txsize unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);