Skip to content

Commit

Permalink
fix(cli): handle case when first transaction range is None on `reth…
Browse files Browse the repository at this point in the history
… db stats` (#11107)
  • Loading branch information
joshieDo authored Sep 22, 2024
1 parent 52c72a3 commit 0a6845b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crates/cli/commands/src/db/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,18 @@ impl Command {

let block_range =
SegmentRangeInclusive::new(first_ranges.0.start(), last_ranges.0.end());
let tx_range = first_ranges
.1
.zip(last_ranges.1)
.map(|(first, last)| SegmentRangeInclusive::new(first.start(), last.end()));

// Transaction ranges can be empty, so we need to find the first and last which are
// not.
let tx_range = {
let start = ranges
.iter()
.find_map(|(_, tx_range)| tx_range.map(|r| r.start()))
.unwrap_or_default();
let end =
ranges.iter().rev().find_map(|(_, tx_range)| tx_range.map(|r| r.end()));
end.map(|end| SegmentRangeInclusive::new(start, end))
};

let mut row = Row::new();
row.add_cell(Cell::new(segment))
Expand Down

0 comments on commit 0a6845b

Please sign in to comment.