mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
change TestLockPointValidity to take a const reference
The lockpoints are not changed in this function. There is no reason to pass a pointer.
This commit is contained in:
parent
b01784f027
commit
c4efc4db54
3 changed files with 7 additions and 8 deletions
|
@ -73,16 +73,15 @@ private:
|
||||||
const LockPoints& lp;
|
const LockPoints& lp;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp)
|
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
assert(lp);
|
|
||||||
// If there are relative lock times then the maxInputBlock will be set
|
// If there are relative lock times then the maxInputBlock will be set
|
||||||
// If there are no relative lock times, the LockPoints don't depend on the chain
|
// If there are no relative lock times, the LockPoints don't depend on the chain
|
||||||
if (lp->maxInputBlock) {
|
if (lp.maxInputBlock) {
|
||||||
// Check whether active_chain is an extension of the block at which the LockPoints
|
// Check whether active_chain is an extension of the block at which the LockPoints
|
||||||
// calculation was valid. If not LockPoints are no longer valid
|
// calculation was valid. If not LockPoints are no longer valid
|
||||||
if (!active_chain.Contains(lp->maxInputBlock)) {
|
if (!active_chain.Contains(lp.maxInputBlock)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,8 +648,8 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check
|
||||||
}
|
}
|
||||||
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
|
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
|
||||||
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++) {
|
||||||
LockPoints lp = it->GetLockPoints();
|
const LockPoints lp{it->GetLockPoints()};
|
||||||
if (!TestLockPointValidity(chain, &lp)) {
|
if (!TestLockPointValidity(chain, lp)) {
|
||||||
mapTx.modify(it, update_lock_points(lp));
|
mapTx.modify(it, update_lock_points(lp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ struct LockPoints {
|
||||||
/**
|
/**
|
||||||
* Test whether the LockPoints height and time are still valid on the current chain
|
* Test whether the LockPoints height and time are still valid on the current chain
|
||||||
*/
|
*/
|
||||||
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
struct CompareIteratorByHash {
|
struct CompareIteratorByHash {
|
||||||
// SFINAE for T where T is either a pointer type (e.g., a txiter) or a reference_wrapper<T>
|
// SFINAE for T where T is either a pointer type (e.g., a txiter) or a reference_wrapper<T>
|
||||||
|
|
|
@ -357,7 +357,7 @@ void CChainState::MaybeUpdateMempoolForReorg(
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
const CTransaction& tx = it->GetTx();
|
const CTransaction& tx = it->GetTx();
|
||||||
LockPoints lp = it->GetLockPoints();
|
LockPoints lp = it->GetLockPoints();
|
||||||
const bool validLP{TestLockPointValidity(m_chain, &lp)};
|
const bool validLP{TestLockPointValidity(m_chain, lp)};
|
||||||
CCoinsViewMemPool view_mempool(&CoinsTip(), *m_mempool);
|
CCoinsViewMemPool view_mempool(&CoinsTip(), *m_mempool);
|
||||||
if (!CheckFinalTx(m_chain.Tip(), tx, flags)
|
if (!CheckFinalTx(m_chain.Tip(), tx, flags)
|
||||||
|| !CheckSequenceLocks(m_chain.Tip(), view_mempool, tx, flags, &lp, validLP)) {
|
|| !CheckSequenceLocks(m_chain.Tip(), view_mempool, tx, flags, &lp, validLP)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue