Skip to content

Commit

Permalink
fix: prevent panic when scanning from genesis block
Browse files Browse the repository at this point in the history
It prevents a u64 from getting a negative value when computing the
parent block height of the genesis block (#0).
  • Loading branch information
qustavo committed Sep 13, 2023
1 parent 59040eb commit b344eaf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/chainhook-sdk/src/indexer/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,10 @@ pub fn standardize_bitcoin_block(
.previousblockhash
.unwrap_or(BlockHash::all_zeros().to_string())
),
index: block_height - 1,
index: match block_height {
0 => 0,
_ => block_height - 1,
},
},
timestamp: block.time as u32,
metadata: BitcoinBlockMetadata {
Expand Down

0 comments on commit b344eaf

Please sign in to comment.