Move safe TX checks into TestForBlock and TestPackageTransactions
Otherwise we'll miss checks for ancestors.
This commit is contained in:
parent
4d3365ddb2
commit
041a1c26d0
@ -287,11 +287,15 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOp
|
||||
|
||||
// Perform transaction-level checks before adding to block:
|
||||
// - transaction finality (locktime)
|
||||
// - safe TXs in regard to ChainLocks
|
||||
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
|
||||
{
|
||||
BOOST_FOREACH (const CTxMemPool::txiter it, package) {
|
||||
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
|
||||
return false;
|
||||
if (!llmq::chainLocksHandler->IsTxSafeForMining(it->GetTx().GetHash())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -333,6 +337,10 @@ bool BlockAssembler::TestForBlock(CTxMemPool::txiter iter)
|
||||
if (!IsFinalTx(iter->GetTx(), nHeight, nLockTimeCutoff))
|
||||
return false;
|
||||
|
||||
if (!llmq::chainLocksHandler->IsTxSafeForMining(iter->GetTx().GetHash())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -454,12 +462,6 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mi != mempool.mapTx.get<ancestor_score>().end() &&
|
||||
!llmq::chainLocksHandler->IsTxSafeForMining(mi->GetTx().GetHash())) {
|
||||
++mi;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now that mi is not stale, determine which transaction to evaluate:
|
||||
// the next entry from mapTx, or the best from mapModifiedTx?
|
||||
bool fUsingModified = false;
|
||||
@ -530,7 +532,7 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
|
||||
onlyUnconfirmed(ancestors);
|
||||
ancestors.insert(iter);
|
||||
|
||||
// Test if all tx's are Final
|
||||
// Test if all tx's are Final and safe
|
||||
if (!TestPackageTransactions(ancestors)) {
|
||||
if (fUsingModified) {
|
||||
mapModifiedTx.get<ancestor_score>().erase(modit);
|
||||
@ -608,10 +610,6 @@ void BlockAssembler::addPriorityTxs()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!llmq::chainLocksHandler->IsTxSafeForMining(iter->GetTx().GetHash())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this tx fits in the block add it, otherwise keep looping
|
||||
if (TestForBlock(iter)) {
|
||||
AddToBlock(iter);
|
||||
|
Loading…
Reference in New Issue
Block a user