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 Sep 5, 2023
1 parent fd35014 commit 05be1c5
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 @@ -669,6 +669,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 05be1c5

Please sign in to comment.