diff options
| author | Gavin Andresen <[email protected]> | 2012-07-26 15:29:59 -0400 |
|---|---|---|
| committer | Gavin Andresen <[email protected]> | 2012-07-26 15:29:59 -0400 |
| commit | e0e54740b10e28dac2fe7aa9b461e956452e9649 (patch) | |
| tree | 11f5133cd35c7a55f347e0a67883d242b923d3e5 /src/main.cpp | |
| parent | When creating new blocks, sort 'paid' area by fee-per-kb (diff) | |
| download | discoin-e0e54740b10e28dac2fe7aa9b461e956452e9649.tar.xz discoin-e0e54740b10e28dac2fe7aa9b461e956452e9649.zip | |
Handle should-never-happen case of orphan in mempool
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 7973e6383..98eff597f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3425,6 +3425,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) 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 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) 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 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) 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); |