Skip to content

Commit d2cbdc4

Browse files
committed
merge bitcoin#23630: Remove GetSpendHeight
1 parent 8bdab4d commit d2cbdc4

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/node/blockstorage.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ class BlockManager
185185

186186
//! Check whether the block associated with this index entry is pruned or not.
187187
bool IsBlockPruned(const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
188-
189-
/**
190-
* Return the spend height, which is one more than the inputs.GetBestBlock().
191-
* While checking, GetBestBlock() refers to the parent block. (protected by cs_main)
192-
* This is also true for mempool checks.
193-
*/
194-
int GetSpendHeight(const CCoinsViewCache& inputs) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
195188
};
196189

197190
void CleanupBlockRevFiles();

src/validation.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
693693
// to coins_to_uncache)
694694
m_view.SetBackend(m_dummy);
695695

696+
assert(m_active_chainstate.m_blockman.LookupBlockIndex(m_view.GetBestBlock()) == m_active_chainstate.m_chain.Tip());
697+
696698
// Only accept BIP68 sequence locked transactions that can be mined in the next
697699
// block; we don't want our mempool filled up with transactions that can't
698700
// be mined yet.
@@ -701,7 +703,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
701703
if (!CheckSequenceLocks(m_active_chainstate.m_chain.Tip(), m_view, tx, STANDARD_LOCKTIME_VERIFY_FLAGS, &lp))
702704
return state.Invalid(TxValidationResult::TX_PREMATURE_SPEND, "non-BIP68-final");
703705

704-
if (!Consensus::CheckTxInputs(tx, state, m_view, m_active_chainstate.m_blockman.GetSpendHeight(m_view), ws.m_base_fees)) {
706+
// The mempool holds txs for the next block, so pass height+1 to CheckTxInputs
707+
if (!Consensus::CheckTxInputs(tx, state, m_view, m_active_chainstate.m_chain.Height() + 1, ws.m_base_fees)) {
705708
return false; // state filled in by CheckTxInputs
706709
}
707710

@@ -1401,14 +1404,6 @@ bool CScriptCheck::operator()() {
14011404
return VerifyScript(scriptSig, m_tx_out.scriptPubKey, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, m_tx_out.nValue, txdata, cacheStore), &error);
14021405
}
14031406

1404-
int BlockManager::GetSpendHeight(const CCoinsViewCache& inputs)
1405-
{
1406-
AssertLockHeld(cs_main);
1407-
CBlockIndex* pindexPrev = LookupBlockIndex(inputs.GetBestBlock());
1408-
return pindexPrev->nHeight + 1;
1409-
}
1410-
1411-
14121407
static CuckooCache::cache<uint256, SignatureCacheHasher> g_scriptExecutionCache;
14131408
static CSHA256 g_scriptExecutionCacheHasher;
14141409

0 commit comments

Comments
 (0)