Skip to content

Commit

Permalink
fix: don't assume that the bitcoin node always gives a non-zero numbe…
Browse files Browse the repository at this point in the history
…r of headers
  • Loading branch information
jcnelson authored and stjepangolemac committed Apr 20, 2023
1 parent 4cd74b9 commit 3c243ff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/burnchains/bitcoin/spv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,11 @@ impl SpvClient {
assert!(self.readwrite, "SPV header DB is open read-only");

let num_headers = block_headers.len();
if num_headers == 0 {
// nothing to do
return Ok(());
}

let first_header_hash = block_headers[0].header.bitcoin_hash();
let last_header_hash = block_headers[block_headers.len() - 1].header.bitcoin_hash();
let total_work_before = self.update_chain_work()?;
Expand Down

0 comments on commit 3c243ff

Please sign in to comment.