Skip to content

Commit 6dafa6d

Browse files
committed
Fix address stats with re-orged history entries
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.
1 parent 85b8baf commit 6dafa6d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/new_index/schema.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,9 @@ impl ChainQuery {
676676
.map(TxHistoryRow::from_row)
677677
.filter_map(|history| {
678678
self.tx_confirming_block(&history.get_txid())
679+
// drop history entries that were previously confirmed in a re-orged block and later
680+
// confirmed again at a different height
681+
.filter(|blockid| blockid.height == history.key.confirmed_height as usize)
679682
.map(|blockid| (history, blockid))
680683
});
681684

0 commit comments

Comments
 (0)