Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs
This commit is contained in:
17
src/main.h
17
src/main.h
@@ -339,6 +339,8 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state,
|
|||||||
/** 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, CCoinsViewCache& inputs, int nHeight);
|
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
|
||||||
|
|
||||||
|
/** Transaction validation functions */
|
||||||
|
|
||||||
/** Context-independent validity checks */
|
/** Context-independent validity checks */
|
||||||
bool CheckTransaction(const CTransaction& tx, CValidationState& state, libzcash::ProofVerifier& verifier);
|
bool CheckTransaction(const CTransaction& tx, CValidationState& state, libzcash::ProofVerifier& verifier);
|
||||||
bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state);
|
bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state);
|
||||||
@@ -348,6 +350,17 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
|
|||||||
*/
|
*/
|
||||||
bool IsStandardTx(const CTransaction& tx, std::string& reason, int nHeight = 0);
|
bool IsStandardTx(const CTransaction& tx, std::string& reason, int nHeight = 0);
|
||||||
|
|
||||||
|
namespace Consensus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether all inputs of this transaction are valid (no double spends and amounts)
|
||||||
|
* This does not modify the UTXO set. This does not check scripts and sigs.
|
||||||
|
* Preconditions: tx.IsCoinBase() is false.
|
||||||
|
*/
|
||||||
|
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, const Consensus::Params& consensusParams);
|
||||||
|
|
||||||
|
} // namespace Consensus
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if transaction is final and can be included in a block with the
|
* Check if transaction is final and can be included in a block with the
|
||||||
* specified height and time. Consensus critical.
|
* specified height and time. Consensus critical.
|
||||||
@@ -536,10 +549,6 @@ extern CBlockTreeDB *pblocktree;
|
|||||||
*/
|
*/
|
||||||
int GetSpendHeight(const CCoinsViewCache& inputs);
|
int GetSpendHeight(const CCoinsViewCache& inputs);
|
||||||
|
|
||||||
namespace Consensus {
|
|
||||||
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, const Consensus::Params& consensusParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return a CMutableTransaction with contextual default values based on set of consensus rules at height */
|
/** Return a CMutableTransaction with contextual default values based on set of consensus rules at height */
|
||||||
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight);
|
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight);
|
||||||
|
|
||||||
|
|||||||
@@ -329,6 +329,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
|||||||
uint64_t innerUsage = 0;
|
uint64_t innerUsage = 0;
|
||||||
|
|
||||||
CCoinsViewCache mempoolDuplicate(const_cast<CCoinsViewCache*>(pcoins));
|
CCoinsViewCache mempoolDuplicate(const_cast<CCoinsViewCache*>(pcoins));
|
||||||
|
const int64_t nSpendHeight = GetSpendHeight(mempoolDuplicate);
|
||||||
|
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
list<const CTxMemPoolEntry*> waitingOnDependants;
|
list<const CTxMemPoolEntry*> waitingOnDependants;
|
||||||
@@ -383,7 +384,9 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
|||||||
waitingOnDependants.push_back(&(*it));
|
waitingOnDependants.push_back(&(*it));
|
||||||
else {
|
else {
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
assert(ContextualCheckInputs(tx, state, mempoolDuplicate, false, 0, false, Params().GetConsensus(), NULL));
|
bool fCheckResult = tx.IsCoinBase() ||
|
||||||
|
Consensus::CheckTxInputs(tx, state, mempoolDuplicate, nSpendHeight, Params().GetConsensus());
|
||||||
|
assert(fCheckResult);
|
||||||
UpdateCoins(tx, mempoolDuplicate, 1000000);
|
UpdateCoins(tx, mempoolDuplicate, 1000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,7 +400,9 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
|||||||
stepsSinceLastRemove++;
|
stepsSinceLastRemove++;
|
||||||
assert(stepsSinceLastRemove < waitingOnDependants.size());
|
assert(stepsSinceLastRemove < waitingOnDependants.size());
|
||||||
} else {
|
} else {
|
||||||
assert(ContextualCheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, Params().GetConsensus(), NULL));
|
bool fCheckResult = entry->GetTx().IsCoinBase() ||
|
||||||
|
Consensus::CheckTxInputs(entry->GetTx(), state, mempoolDuplicate, nSpendHeight, Params().GetConsensus());
|
||||||
|
assert(fCheckResult);
|
||||||
UpdateCoins(entry->GetTx(), mempoolDuplicate, 1000000);
|
UpdateCoins(entry->GetTx(), mempoolDuplicate, 1000000);
|
||||||
stepsSinceLastRemove = 0;
|
stepsSinceLastRemove = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user