diff options
author | Carl Dong <contact@carldong.me> | 2020-08-25 17:11:32 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-01-28 14:15:26 -0500 |
commit | e4b95eefbc700ebc915bec312f77477ce3e87a7e (patch) | |
tree | b04b3effd3a1c27b2cddae75ded9ec262982bd96 /src/validation.cpp | |
parent | b026e318c39f59a06e29f1b25c7f577e01b25ccb (diff) | |
download | bitcoin-e4b95eefbc700ebc915bec312f77477ce3e87a7e.tar.xz |
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.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 69207fb529..7e3957d8d8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -684,7 +684,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws) return state.Invalid(TxValidationResult::TX_PREMATURE_SPEND, "non-BIP68-final"); 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 } @@ -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); } -int GetSpendHeight(const CCoinsViewCache& inputs) +int BlockManager::GetSpendHeight(const CCoinsViewCache& inputs) { - LOCK(cs_main); - CBlockIndex* pindexPrev = g_chainman.m_blockman.LookupBlockIndex(inputs.GetBestBlock()); + AssertLockHeld(cs_main); + assert(std::addressof(g_chainman.m_blockman) == std::addressof(*this)); + CBlockIndex* pindexPrev = LookupBlockIndex(inputs.GetBestBlock()); return pindexPrev->nHeight + 1; } |