mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
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:
|
// Perform transaction-level checks before adding to block:
|
||||||
// - transaction finality (locktime)
|
// - transaction finality (locktime)
|
||||||
|
// - safe TXs in regard to ChainLocks
|
||||||
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
|
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH (const CTxMemPool::txiter it, package) {
|
BOOST_FOREACH (const CTxMemPool::txiter it, package) {
|
||||||
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
|
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
|
||||||
return false;
|
return false;
|
||||||
|
if (!llmq::chainLocksHandler->IsTxSafeForMining(it->GetTx().GetHash())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -333,6 +337,10 @@ bool BlockAssembler::TestForBlock(CTxMemPool::txiter iter)
|
|||||||
if (!IsFinalTx(iter->GetTx(), nHeight, nLockTimeCutoff))
|
if (!IsFinalTx(iter->GetTx(), nHeight, nLockTimeCutoff))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!llmq::chainLocksHandler->IsTxSafeForMining(iter->GetTx().GetHash())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,12 +462,6 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
|
|||||||
continue;
|
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:
|
// Now that mi is not stale, determine which transaction to evaluate:
|
||||||
// the next entry from mapTx, or the best from mapModifiedTx?
|
// the next entry from mapTx, or the best from mapModifiedTx?
|
||||||
bool fUsingModified = false;
|
bool fUsingModified = false;
|
||||||
@ -530,7 +532,7 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
|
|||||||
onlyUnconfirmed(ancestors);
|
onlyUnconfirmed(ancestors);
|
||||||
ancestors.insert(iter);
|
ancestors.insert(iter);
|
||||||
|
|
||||||
// Test if all tx's are Final
|
// Test if all tx's are Final and safe
|
||||||
if (!TestPackageTransactions(ancestors)) {
|
if (!TestPackageTransactions(ancestors)) {
|
||||||
if (fUsingModified) {
|
if (fUsingModified) {
|
||||||
mapModifiedTx.get<ancestor_score>().erase(modit);
|
mapModifiedTx.get<ancestor_score>().erase(modit);
|
||||||
@ -608,10 +610,6 @@ void BlockAssembler::addPriorityTxs()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!llmq::chainLocksHandler->IsTxSafeForMining(iter->GetTx().GetHash())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this tx fits in the block add it, otherwise keep looping
|
// If this tx fits in the block add it, otherwise keep looping
|
||||||
if (TestForBlock(iter)) {
|
if (TestForBlock(iter)) {
|
||||||
AddToBlock(iter);
|
AddToBlock(iter);
|
||||||
|
Loading…
Reference in New Issue
Block a user