aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-01-10 20:45:55 -0500
committerGavin Andresen <gavinandresen@gmail.com>2012-01-13 10:22:24 -0500
commit4063460534768e2062585573548c293b39313a41 (patch)
treed7690c9ee4254d0169d0c16a84c2996383da1b87 /src/main.cpp
parent8d7849b6db5f54dc32fe4f8c6c7283068473cd21 (diff)
downloadbitcoin-4063460534768e2062585573548c293b39313a41.tar.xz
Refactor: needing to call ConnectInputs to process coinbase transactions was counter-intuitive
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3a43f5eb36..3c3f066042 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1111,17 +1111,6 @@ bool CTransaction::ConnectInputs(MapPrevTx inputs,
return DoS(100, error("ConnectInputs() : nFees out of range"));
}
- if (fBlock)
- {
- // Add transaction to changes
- mapTestPool[GetHash()] = CTxIndex(posThisTx, vout.size());
- }
- else if (fMiner)
- {
- // Add transaction to test pool
- mapTestPool[GetHash()] = CTxIndex(CDiskTxPos(1,1,1), vout.size());
- }
-
return true;
}
@@ -1226,12 +1215,12 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
// (AcceptBlock() is always called before ConnectBlock())
nFees += tx.GetValueIn(mapInputs)-tx.GetValueOut();
+
+ if (!tx.ConnectInputs(mapInputs, mapQueuedChanges, posThisTx, pindex, true, false))
+ return false;
}
- // It seems wrong that ConnectInputs must be called on the coinbase transaction
- // (which has no inputs) : TODO: refactor the code at the end of ConnectInputs out...
- if (!tx.ConnectInputs(mapInputs, mapQueuedChanges, posThisTx, pindex, true, false))
- return false;
+ mapQueuedChanges[tx.GetHash()] = CTxIndex(posThisTx, tx.vout.size());
}
// Write queued txindex changes
@@ -3087,6 +3076,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
if (!tx.ConnectInputs(mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, false, true))
continue;
+ mapTestPoolTmp[tx.GetHash()] = CTxIndex(CDiskTxPos(1,1,1), tx.vout.size());
swap(mapTestPool, mapTestPoolTmp);
// Added