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
updateIthas no children insetExclude, then there’s no need to check the cache for any descendants as only entries insetExcludeget into the cache. - If
updateIthas no parents, then a subsequent iteration of the loop inUpdateTransactionsFromBlockwon’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.