Before this commit, the stageEntries loop could skip a cache lookup since it was done on the grand-children of updateIt initially and not the direct children. This commit changes the logic so that the cache is queried even for the children of updateIt. Additionally, if updateIt has no children in setExclude, it is possible to avoid the cache lookups. And if updateIt has no parents, it is possible to avoid cache insertions.
- If
updateIt
has no children insetExclude
, then there’s no need to check the cache for any descendants as only entries insetExclude
get into the cache. - If
updateIt
has no parents, then a subsequent iteration of the loop inUpdateTransactionsFromBlock
won’t use the cache entry forupdateIt
.
Prior to this commit, if we had the following tx chain (tx0 is the ancestor of all):
0tx0 <- tx1 <- tx2 <- [tx3, not in setExclude]
then the stageEntries.empty
loop would only query the cache when updateIt
was tx0. When updateIt
is tx2 or tx1, the cache would not be queried since one “generation” of descendants is effectively skipped for lookup.