Skip to content

Commit

Permalink
Do a checked_sub instead.
Browse files Browse the repository at this point in the history
I put the integer being subtracted from in the error to distinguish
from rust panic message.
  • Loading branch information
tbro committed Dec 19, 2024
1 parent 419651a commit 5e21b36
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sequencer/src/api/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ async fn load_frontier<Mode: TransactionMode>(
) -> anyhow::Result<BlocksFrontier> {
tx.get_path(
Snapshot::<SeqTypes, BlockMerkleTree, { BlockMerkleTree::ARITY }>::Index(height),
height - 1,
height
.checked_sub(1)
.ok_or(anyhow::anyhow!("Subtract with overflow ({height})!"))?,
)
.await
.context(format!("fetching frontier at height {height}"))
Expand Down

0 comments on commit 5e21b36

Please sign in to comment.