aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjtimon <jtimon@blockstream.io>2014-10-27 16:07:50 +0100
committerjtimon <jtimon@jtimon.cc>2014-12-27 16:01:12 +0100
commitd7621ccf9d064db19de742ed1a0ac59fffa06c0d (patch)
tree99bd104ad829f2a03efa7119c472e03ab2eea479
parentc444c620c62c51d65f7de0b2a3c351e61ab1e388 (diff)
downloadbitcoin-d7621ccf9d064db19de742ed1a0ac59fffa06c0d.tar.xz
Decouple miner.o and txmempool.o from CTxUndo
-rw-r--r--src/main.cpp6
-rw-r--r--src/main.h2
-rw-r--r--src/miner.cpp3
-rw-r--r--src/txmempool.cpp7
4 files changed, 11 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3f775e3d33..bcd3a5ff05 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1404,6 +1404,12 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
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()() {
const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
if (!VerifyScript(scriptSig, scriptPubKey, nFlags, CachingSignatureChecker(*ptxTo, nIn, cacheStore), &error)) {
diff --git a/src/main.h b/src/main.h
index 662d5756f7..e38b413be1 100644
--- a/src/main.h
+++ b/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);
/** 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 */
bool CheckTransaction(const CTransaction& tx, CValidationState& state);
diff --git a/src/miner.cpp b/src/miner.cpp
index 2133b13e62..0ac974d6e1 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -279,8 +279,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true))
continue;
- CTxUndo txundo;
- UpdateCoins(tx, state, view, txundo, nHeight);
+ UpdateCoins(tx, state, view, nHeight);
// Added
pblock->vtx.push_back(tx);
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 3071ab025c..01bf1ec080 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -585,9 +585,9 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
if (fDependsWait)
waitingOnDependants.push_back(&it->second);
else {
- CValidationState state; CTxUndo undo;
+ CValidationState state;
assert(CheckInputs(tx, state, mempoolDuplicate, false, 0, false, NULL));
- UpdateCoins(tx, state, mempoolDuplicate, undo, 1000000);
+ UpdateCoins(tx, state, mempoolDuplicate, 1000000);
}
}
unsigned int stepsSinceLastRemove = 0;
@@ -601,8 +601,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
assert(stepsSinceLastRemove < waitingOnDependants.size());
} else {
assert(CheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, NULL));
- CTxUndo undo;
- UpdateCoins(entry->GetTx(), state, mempoolDuplicate, undo, 1000000);
+ UpdateCoins(entry->GetTx(), state, mempoolDuplicate, 1000000);
stepsSinceLastRemove = 0;
}
}