mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-05-17 23:56:39 +00:00
validation: Move GetSpendHeight to BlockManager
[META] This commit should be followed up by removing the comments and assertions meant only to show that the change is correct. GetSpendHeight only acts on BlockManager.
This commit is contained in:
parent
b026e318c3
commit
e4b95eefbc
@ -626,7 +626,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 spendheight = GetSpendHeight(mempoolDuplicate);
|
const int64_t spendheight = g_chainman.m_blockman.GetSpendHeight(mempoolDuplicate);
|
||||||
|
|
||||||
std::list<const CTxMemPoolEntry*> waitingOnDependants;
|
std::list<const CTxMemPoolEntry*> waitingOnDependants;
|
||||||
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
|
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
|
||||||
|
@ -684,7 +684,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||||||
return state.Invalid(TxValidationResult::TX_PREMATURE_SPEND, "non-BIP68-final");
|
return state.Invalid(TxValidationResult::TX_PREMATURE_SPEND, "non-BIP68-final");
|
||||||
|
|
||||||
CAmount nFees = 0;
|
CAmount nFees = 0;
|
||||||
if (!Consensus::CheckTxInputs(tx, state, m_view, GetSpendHeight(m_view), nFees)) {
|
if (!Consensus::CheckTxInputs(tx, state, m_view, g_chainman.m_blockman.GetSpendHeight(m_view), nFees)) {
|
||||||
return false; // state filled in by CheckTxInputs
|
return false; // state filled in by CheckTxInputs
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1412,10 +1412,11 @@ bool CScriptCheck::operator()() {
|
|||||||
return VerifyScript(scriptSig, m_tx_out.scriptPubKey, witness, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, m_tx_out.nValue, cacheStore, *txdata), &error);
|
return VerifyScript(scriptSig, m_tx_out.scriptPubKey, witness, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, m_tx_out.nValue, cacheStore, *txdata), &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetSpendHeight(const CCoinsViewCache& inputs)
|
int BlockManager::GetSpendHeight(const CCoinsViewCache& inputs)
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
CBlockIndex* pindexPrev = g_chainman.m_blockman.LookupBlockIndex(inputs.GetBestBlock());
|
assert(std::addressof(g_chainman.m_blockman) == std::addressof(*this));
|
||||||
|
CBlockIndex* pindexPrev = LookupBlockIndex(inputs.GetBestBlock());
|
||||||
return pindexPrev->nHeight + 1;
|
return pindexPrev->nHeight + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,6 +433,13 @@ public:
|
|||||||
/** Find the last common block between the parameter chain and a locator. */
|
/** Find the last common block between the parameter chain and a locator. */
|
||||||
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the spend height, which is one more than the inputs.GetBestBlock().
|
||||||
|
* While checking, GetBestBlock() refers to the parent block. (protected by cs_main)
|
||||||
|
* This is also true for mempool checks.
|
||||||
|
*/
|
||||||
|
int GetSpendHeight(const CCoinsViewCache& inputs) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
~BlockManager() {
|
~BlockManager() {
|
||||||
Unload();
|
Unload();
|
||||||
}
|
}
|
||||||
@ -945,13 +952,6 @@ CChain& ChainActive();
|
|||||||
/** Global variable that points to the active block tree (protected by cs_main) */
|
/** Global variable that points to the active block tree (protected by cs_main) */
|
||||||
extern std::unique_ptr<CBlockTreeDB> pblocktree;
|
extern std::unique_ptr<CBlockTreeDB> pblocktree;
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the spend height, which is one more than the inputs.GetBestBlock().
|
|
||||||
* While checking, GetBestBlock() refers to the parent block. (protected by cs_main)
|
|
||||||
* This is also true for mempool checks.
|
|
||||||
*/
|
|
||||||
int GetSpendHeight(const CCoinsViewCache& inputs);
|
|
||||||
|
|
||||||
extern VersionBitsCache versionbitscache;
|
extern VersionBitsCache versionbitscache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user