|
|
|
@ -75,7 +75,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
|
|
|
|
|
}
|
|
|
|
|
// descendants now contains all in-mempool descendants of updateIt.
|
|
|
|
|
// Update and add to cached descendant map
|
|
|
|
|
int64_t modifySize = 0;
|
|
|
|
|
int32_t modifySize = 0;
|
|
|
|
|
CAmount modifyFee = 0;
|
|
|
|
|
int64_t modifyCount = 0;
|
|
|
|
|
for (const CTxMemPoolEntry& descendant : descendants) {
|
|
|
|
@ -91,7 +91,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
|
|
|
|
|
// Don't directly remove the transaction here -- doing so would
|
|
|
|
|
// invalidate iterators in cachedDescendants. Mark it for removal
|
|
|
|
|
// by inserting into descendants_to_remove.
|
|
|
|
|
if (descendant.GetCountWithAncestors() > uint64_t(m_limits.ancestor_count) || descendant.GetSizeWithAncestors() > uint64_t(m_limits.ancestor_size_vbytes)) {
|
|
|
|
|
if (descendant.GetCountWithAncestors() > uint64_t(m_limits.ancestor_count) || descendant.GetSizeWithAncestors() > m_limits.ancestor_size_vbytes) {
|
|
|
|
|
descendants_to_remove.insert(descendant.GetTx().GetHash());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -278,8 +278,8 @@ void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors
|
|
|
|
|
for (const CTxMemPoolEntry& parent : parents) {
|
|
|
|
|
UpdateChild(mapTx.iterator_to(parent), it, add);
|
|
|
|
|
}
|
|
|
|
|
const int64_t updateCount = (add ? 1 : -1);
|
|
|
|
|
const int64_t updateSize = updateCount * it->GetTxSize();
|
|
|
|
|
const int32_t updateCount = (add ? 1 : -1);
|
|
|
|
|
const int32_t updateSize{updateCount * it->GetTxSize()};
|
|
|
|
|
const CAmount updateFee = updateCount * it->GetModifiedFee();
|
|
|
|
|
for (txiter ancestorIt : setAncestors) {
|
|
|
|
|
mapTx.modify(ancestorIt, [=](CTxMemPoolEntry& e) { e.UpdateDescendantState(updateSize, updateFee, updateCount); });
|
|
|
|
@ -323,7 +323,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
|
|
|
|
|
setEntries setDescendants;
|
|
|
|
|
CalculateDescendants(removeIt, setDescendants);
|
|
|
|
|
setDescendants.erase(removeIt); // don't update state for self
|
|
|
|
|
int64_t modifySize = -((int64_t)removeIt->GetTxSize());
|
|
|
|
|
int32_t modifySize = -removeIt->GetTxSize();
|
|
|
|
|
CAmount modifyFee = -removeIt->GetModifiedFee();
|
|
|
|
|
int modifySigOps = -removeIt->GetSigOpCost();
|
|
|
|
|
for (txiter dit : setDescendants) {
|
|
|
|
@ -365,19 +365,19 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
|
|
|
|
|
void CTxMemPoolEntry::UpdateDescendantState(int32_t modifySize, CAmount modifyFee, int64_t modifyCount)
|
|
|
|
|
{
|
|
|
|
|
nSizeWithDescendants += modifySize;
|
|
|
|
|
assert(int64_t(nSizeWithDescendants) > 0);
|
|
|
|
|
assert(nSizeWithDescendants > 0);
|
|
|
|
|
nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, modifyFee);
|
|
|
|
|
nCountWithDescendants += modifyCount;
|
|
|
|
|
assert(int64_t(nCountWithDescendants) > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
|
|
|
|
|
void CTxMemPoolEntry::UpdateAncestorState(int32_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
|
|
|
|
|
{
|
|
|
|
|
nSizeWithAncestors += modifySize;
|
|
|
|
|
assert(int64_t(nSizeWithAncestors) > 0);
|
|
|
|
|
assert(nSizeWithAncestors > 0);
|
|
|
|
|
nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, modifyFee);
|
|
|
|
|
nCountWithAncestors += modifyCount;
|
|
|
|
|
assert(int64_t(nCountWithAncestors) > 0);
|
|
|
|
@ -699,7 +699,7 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
|
|
|
|
|
// Verify ancestor state is correct.
|
|
|
|
|
auto ancestors{AssumeCalculateMemPoolAncestors(__func__, *it, Limits::NoLimits())};
|
|
|
|
|
uint64_t nCountCheck = ancestors.size() + 1;
|
|
|
|
|
uint64_t nSizeCheck = it->GetTxSize();
|
|
|
|
|
int32_t nSizeCheck = it->GetTxSize();
|
|
|
|
|
CAmount nFeesCheck = it->GetModifiedFee();
|
|
|
|
|
int64_t nSigOpCheck = it->GetSigOpCost();
|
|
|
|
|
|
|
|
|
@ -720,7 +720,7 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
|
|
|
|
|
// Check children against mapNextTx
|
|
|
|
|
CTxMemPoolEntry::Children setChildrenCheck;
|
|
|
|
|
auto iter = mapNextTx.lower_bound(COutPoint(it->GetTx().GetHash(), 0));
|
|
|
|
|
uint64_t child_sizes = 0;
|
|
|
|
|
int32_t child_sizes{0};
|
|
|
|
|
for (; iter != mapNextTx.end() && iter->first->hash == it->GetTx().GetHash(); ++iter) {
|
|
|
|
|
txiter childit = mapTx.find(iter->second->GetHash());
|
|
|
|
|
assert(childit != mapTx.end()); // mapNextTx points to in-mempool transactions
|
|
|
|
|