Browse Source

Decouple miner.o and txmempool.o from CTxUndo

0.13
jtimon 10 years ago committed by jtimon
parent
commit
d7621ccf9d
  1. 6
      src/main.cpp
  2. 2
      src/main.h
  3. 3
      src/miner.cpp
  4. 7
      src/txmempool.cpp

6
src/main.cpp

@ -1404,6 +1404,12 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight); inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight);
} }
void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight)
{
CTxUndo txundo;
UpdateCoins(tx, state, inputs, txundo, nHeight);
}
bool CScriptCheck::operator()() { bool CScriptCheck::operator()() {
const CScript &scriptSig = ptxTo->vin[nIn].scriptSig; const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
if (!VerifyScript(scriptSig, scriptPubKey, nFlags, CachingSignatureChecker(*ptxTo, nIn, cacheStore), &error)) { if (!VerifyScript(scriptSig, scriptPubKey, nFlags, CachingSignatureChecker(*ptxTo, nIn, cacheStore), &error)) {

2
src/main.h

@ -290,7 +290,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
unsigned int flags, bool cacheStore, std::vector<CScriptCheck> *pvChecks = NULL); unsigned int flags, bool cacheStore, std::vector<CScriptCheck> *pvChecks = NULL);
/** Apply the effects of this transaction on the UTXO set represented by view */ /** Apply the effects of this transaction on the UTXO set represented by view */
void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight); void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight);
/** Context-independent validity checks */ /** Context-independent validity checks */
bool CheckTransaction(const CTransaction& tx, CValidationState& state); bool CheckTransaction(const CTransaction& tx, CValidationState& state);

3
src/miner.cpp

@ -279,8 +279,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true)) if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true))
continue; continue;
CTxUndo txundo; UpdateCoins(tx, state, view, nHeight);
UpdateCoins(tx, state, view, txundo, nHeight);
// Added // Added
pblock->vtx.push_back(tx); pblock->vtx.push_back(tx);

7
src/txmempool.cpp

@ -585,9 +585,9 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
if (fDependsWait) if (fDependsWait)
waitingOnDependants.push_back(&it->second); waitingOnDependants.push_back(&it->second);
else { else {
CValidationState state; CTxUndo undo; CValidationState state;
assert(CheckInputs(tx, state, mempoolDuplicate, false, 0, false, NULL)); assert(CheckInputs(tx, state, mempoolDuplicate, false, 0, false, NULL));
UpdateCoins(tx, state, mempoolDuplicate, undo, 1000000); UpdateCoins(tx, state, mempoolDuplicate, 1000000);
} }
} }
unsigned int stepsSinceLastRemove = 0; unsigned int stepsSinceLastRemove = 0;
@ -601,8 +601,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
assert(stepsSinceLastRemove < waitingOnDependants.size()); assert(stepsSinceLastRemove < waitingOnDependants.size());
} else { } else {
assert(CheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, NULL)); assert(CheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, NULL));
CTxUndo undo; UpdateCoins(entry->GetTx(), state, mempoolDuplicate, 1000000);
UpdateCoins(entry->GetTx(), state, mempoolDuplicate, undo, 1000000);
stepsSinceLastRemove = 0; stepsSinceLastRemove = 0;
} }
} }

Loading…
Cancel
Save