Skip to content

Commit 9703b0e

Browse files
committed
Decouple miner.o and txmempool.o from CTxUndo
[backports bitcoin/bitcoin@d7621cc]
1 parent cdc8cdc commit 9703b0e

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,12 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo& txund
17261726
inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight);
17271727
}
17281728

1729+
void UpdateCoins(const CTransaction& tx, CCoinsViewCache &inputs, int nHeight)
1730+
{
1731+
CTxUndo txundo;
1732+
UpdateCoins(tx, inputs, txundo, nHeight);
1733+
}
1734+
17291735
bool CScriptCheck::operator()()
17301736
{
17311737
const CScript& scriptSig = ptxTo->vin[nIn].scriptSig;

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, const CTxMemPool& pool, unsigned
284284
bool CheckInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& view, bool fScriptChecks, unsigned int flags, bool cacheStore, std::vector<CScriptCheck>* pvChecks = NULL);
285285

286286
/** Apply the effects of this transaction on the UTXO set represented by view */
287-
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo& txundo, int nHeight);
287+
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
288288

289289
bool IsTransactionInChain(const uint256& txId, int& nHeightTx, CTransaction& tx);
290290
bool IsTransactionInChain(const uint256& txId, int& nHeightTx);

src/miner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
372372
if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true))
373373
continue;
374374

375-
CTxUndo txundo;
376-
UpdateCoins(tx, view, txundo, nHeight);
375+
UpdateCoins(tx, view, nHeight);
377376

378377
// Added
379378
pblock->vtx.push_back(tx);

src/txmempool.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,8 @@ void CTxMemPool::check(const CCoinsViewCache* pcoins) const
662662
waitingOnDependants.push_back(&(*it));
663663
else {
664664
CValidationState state;
665-
CTxUndo undo;
666665
assert(CheckInputs(tx, state, mempoolDuplicate, false, 0, false, NULL));
667-
UpdateCoins(tx, mempoolDuplicate, undo, 1000000);
666+
UpdateCoins(tx, mempoolDuplicate, 1000000);
668667
}
669668
}
670669

@@ -679,8 +678,7 @@ void CTxMemPool::check(const CCoinsViewCache* pcoins) const
679678
assert(stepsSinceLastRemove < waitingOnDependants.size());
680679
} else {
681680
assert(CheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, NULL));
682-
CTxUndo undo;
683-
UpdateCoins(entry->GetTx(), mempoolDuplicate, undo, 1000000);
681+
UpdateCoins(entry->GetTx(), mempoolDuplicate, 1000000);
684682
stepsSinceLastRemove = 0;
685683
}
686684
}

0 commit comments

Comments
 (0)