romanz / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
1.02k stars 373 forks source link

avoid redundant recomputation of fee histogram bins #971

Closed conduition closed 6 months ago

conduition commented 6 months ago

Extracted from https://github.com/romanz/electrs/pull/970. This PR is a prereq of #970.

FeeHistogram was being recomputed from scratch on every call to Mempool::sync. This was unnecessary. Instead we can mutate the existing histogram bin state once on each new transaction added to or removed from the mempool.

Prometheus mempool metrics are only updated once per bin at the end of every sync.