Skip to content

Commit

Permalink
Fix address stats with re-orged history entries
Browse files Browse the repository at this point in the history
There might be history entries where the txid ended up confirming at a
different block height following a re-org. Before this fix, these
entries would get counted twice, once with the initial re-orged
confirmation height, then again with the final confirmation height.

See mempool/electrs#12.
  • Loading branch information
shesek committed Feb 16, 2024
1 parent 85b8baf commit 6dafa6d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/new_index/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ impl ChainQuery {
.map(TxHistoryRow::from_row)
.filter_map(|history| {
self.tx_confirming_block(&history.get_txid())
// drop history entries that were previously confirmed in a re-orged block and later
// confirmed again at a different height
.filter(|blockid| blockid.height == history.key.confirmed_height as usize)
.map(|blockid| (history, blockid))
});

Expand Down

0 comments on commit 6dafa6d

Please sign in to comment.