mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -05:00
Make UpdateTransactionsFromBlock use Epochs
This commit is contained in:
parent
2ccb7cca4a
commit
bd5a026928
1 changed files with 14 additions and 12 deletions
|
@ -122,8 +122,6 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
|
||||||
// setMemPoolChildren will be updated, an assumption made in
|
// setMemPoolChildren will be updated, an assumption made in
|
||||||
// UpdateForDescendants.
|
// UpdateForDescendants.
|
||||||
for (const uint256 &hash : reverse_iterate(vHashesToUpdate)) {
|
for (const uint256 &hash : reverse_iterate(vHashesToUpdate)) {
|
||||||
// we cache the in-mempool children to avoid duplicate updates
|
|
||||||
setEntries setChildren;
|
|
||||||
// calculate children from mapNextTx
|
// calculate children from mapNextTx
|
||||||
txiter it = mapTx.find(hash);
|
txiter it = mapTx.find(hash);
|
||||||
if (it == mapTx.end()) {
|
if (it == mapTx.end()) {
|
||||||
|
@ -132,17 +130,21 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
|
||||||
auto iter = mapNextTx.lower_bound(COutPoint(hash, 0));
|
auto iter = mapNextTx.lower_bound(COutPoint(hash, 0));
|
||||||
// First calculate the children, and update setMemPoolChildren to
|
// First calculate the children, and update setMemPoolChildren to
|
||||||
// include them, and update their setMemPoolParents to include this tx.
|
// include them, and update their setMemPoolParents to include this tx.
|
||||||
for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) {
|
// we cache the in-mempool children to avoid duplicate updates
|
||||||
const uint256 &childHash = iter->second->GetHash();
|
{
|
||||||
txiter childIter = mapTx.find(childHash);
|
const auto epoch = GetFreshEpoch();
|
||||||
assert(childIter != mapTx.end());
|
for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) {
|
||||||
// We can skip updating entries we've encountered before or that
|
const uint256 &childHash = iter->second->GetHash();
|
||||||
// are in the block (which are already accounted for).
|
txiter childIter = mapTx.find(childHash);
|
||||||
if (setChildren.insert(childIter).second && !setAlreadyIncluded.count(childHash)) {
|
assert(childIter != mapTx.end());
|
||||||
UpdateChild(it, childIter, true);
|
// We can skip updating entries we've encountered before or that
|
||||||
UpdateParent(childIter, it, true);
|
// are in the block (which are already accounted for).
|
||||||
|
if (!visited(childIter) && !setAlreadyIncluded.count(childHash)) {
|
||||||
|
UpdateChild(it, childIter, true);
|
||||||
|
UpdateParent(childIter, it, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} // release epoch guard for UpdateForDescendants
|
||||||
UpdateForDescendants(it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded);
|
UpdateForDescendants(it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue