Skip to content

Commit 9203886

Browse files
committed
fix: remove index-range option from stacks-inspect
This option adds complexity to the block selection across pre-Nakamoto / Nakamoto blocks and it doesn't seem useful, so remove it. Also, make `range` exclusive of the `end` height.
1 parent e67c961 commit 9203886

File tree

1 file changed

+4
-24
lines changed
  • contrib/stacks-inspect/src

1 file changed

+4
-24
lines changed

contrib/stacks-inspect/src/lib.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ enum BlockSelection {
133133
Prefix(String),
134134
Last(u64),
135135
HeightRange { start: u64, end: u64 },
136-
IndexRange { start: u64, end: u64 },
137136
}
138137

139138
impl BlockSelection {
@@ -147,12 +146,9 @@ impl BlockSelection {
147146
format!("WHERE orphaned = 0 ORDER BY height DESC LIMIT {count}")
148147
}
149148
BlockSelection::HeightRange { start, end } => format!(
150-
"WHERE orphaned = 0 AND height BETWEEN {start} AND {end} ORDER BY height ASC"
149+
"WHERE orphaned = 0 AND height BETWEEN {start} AND {} ORDER BY height ASC",
150+
end - 1 // exclusive end
151151
),
152-
BlockSelection::IndexRange { start, end } => {
153-
let blocks = end.saturating_sub(*start);
154-
format!("WHERE orphaned = 0 ORDER BY index_block_hash ASC LIMIT {start}, {blocks}")
155-
}
156152
}
157153
}
158154
}
@@ -185,27 +181,11 @@ fn parse_block_selection(mode: Option<&str>, argv: &[String]) -> Result<BlockSel
185181
.ok_or_else(|| "Missing <end-block>".to_string())?
186182
.parse::<u64>()
187183
.map_err(|_| "<end-block> must be a u64".to_string())?;
188-
if start > end {
189-
return Err("<start-block> must be <= <end-block>".into());
184+
if start >= end {
185+
return Err("<start-block> must be < <end-block>".into());
190186
}
191187
Ok(BlockSelection::HeightRange { start, end })
192188
}
193-
Some("index-range") => {
194-
let start = argv
195-
.get(3)
196-
.ok_or_else(|| "Missing <start-block>".to_string())?
197-
.parse::<u64>()
198-
.map_err(|_| "<start-block> must be a u64".to_string())?;
199-
let end = argv
200-
.get(4)
201-
.ok_or_else(|| "Missing <end-block>".to_string())?
202-
.parse::<u64>()
203-
.map_err(|_| "<end-block> must be a u64".to_string())?;
204-
if start > end {
205-
return Err("<start-block> must be <= <end-block>".into());
206-
}
207-
Ok(BlockSelection::IndexRange { start, end })
208-
}
209189
Some(other) => Err(format!("Unrecognized option: {other}")),
210190
None => Ok(BlockSelection::All),
211191
}

0 commit comments

Comments
 (0)