Refactor: needing to call ConnectInputs to process coinbase transactions was counter-intuitive
This commit is contained in:
parent
8d7849b6db
commit
4063460534
18
src/main.cpp
18
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,14 +1215,14 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
|
|||
// (AcceptBlock() is always called before ConnectBlock())
|
||||
|
||||
nFees += tx.GetValueIn(mapInputs)-tx.GetValueOut();
|
||||
}
|
||||
|
||||
// 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
|
||||
for (map<uint256, CTxIndex>::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi)
|
||||
{
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue