This implements caching of count, size, (modified) fee, and sigops of each mempool entry with its unconfirmed ancestors.
This is in preparation for adding support to CreateNewBlock
for transaction selection based on fees-with-ancestors, for which I’ll open another pull request soon.
Note that in order to keep accurate ancestor state, CTxMemPool::removeForBlock
has to walk the descendants of each in-block transaction (so that it’s ancestor state can be reflected for the ancestor which was confirmed). The performance hit appears to be relatively insignificant (at least on the mempools I was looking at from 10/1/15 - 10/10/15): it amounted to an average 0.3ms, from 10.9ms to 11.2ms, on my almost 2 year old hardware. Moreover, I think if this performance was ever an issue we could do a bigger re-engineering of ConnectBlock
so that block relay isn’t held up by updating the mempool state.
I would like to also expose this ancestor information via RPC, but will hold off until after #7292, so I might do that in a future PR rather than in this one. Also, the unit tests in this PR will be improved somewhat after #7539.