Taken, also please add an explanation.
I also note a behavior change introduced by this. It is possible that we may track some unconfirmed transactions and, in rare cases, see some unconfirmed transactions get evicted. However, since we have no confirmations yet, if we shut down in this state, we will lose that data and have to start from scratch. To mitigate this, we need a way to detect when we are in such a state.
I see two possible approaches:
- Brute-force check : Go through all the stats to ensure we have no useful data.
- Smart tracking : Add some of flag or tracker to each stat that indicates whether there is any useful data available. This would require extra processing when adding transactions to the mempool and, in rare cases, when transactions are evicted from the mempool.
Also related to this: checking whether MaxUsableEstimate
is non-zero is not sufficient to decide whether we should avoid updating the unconfirmed circular buffer or decaying all exponential averages.
Additionally, simply tracking whether we have ever seen an unconfirmed transaction or a failure is not enough. There is an edge case where you may have seen that event,but if the relevant data has since decayed, you could end up updating with effectively empty stats. The indicator would need to account for data decay to provide an accurate signal.
Given this, I am starting to doubt whether the performance gain is worth the added complexity cc @l0rinc .