aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-07-26 15:29:59 -0400
committerGavin Andresen <gavinandresen@gmail.com>2012-07-26 15:29:59 -0400
commite0e54740b10e28dac2fe7aa9b461e956452e9649 (patch)
tree11f5133cd35c7a55f347e0a67883d242b923d3e5 /src/main.cpp
parentc555400ca134991e39d5e3a565fcd2215abe56f6 (diff)
Handle should-never-happen case of orphan in mempool
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7973e63831..98eff597fc 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);