Skip to content

Commit

Permalink
fix: off by one
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Aug 3, 2023
1 parent 0e3faf9 commit c31611f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/hord-cli/src/cli/mod.rs
Expand Up @@ -798,7 +798,7 @@ pub async fn check_bitcoind_connection(config: &Config) -> Result<u64, String> {
};

let end_block = match bitcoin_rpc.get_blockchain_info() {
Ok(result) => result.blocks.saturating_sub(1),
Ok(result) => result.blocks,
Err(e) => {
return Err(format!("unable to connect to bitcoind: {}", e.to_string()));
}
Expand Down
4 changes: 2 additions & 2 deletions components/hord-cli/src/scan/bitcoin.rs
Expand Up @@ -60,7 +60,7 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
let (end_block, update_end_block) = match predicate_spec.end_block {
Some(end_block) => (end_block, false),
None => match bitcoin_rpc.get_blockchain_info() {
Ok(result) => (result.blocks - 1, true),
Ok(result) => (result.blocks, true),
Err(e) => {
return Err(format!(
"unable to retrieve Bitcoin chain tip ({})",
Expand Down Expand Up @@ -177,7 +177,7 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
if block_heights_to_scan.is_empty() && floating_end_block {
match bitcoin_rpc.get_blockchain_info() {
Ok(result) => {
for entry in (current_block_height + 1)..result.blocks {
for entry in (current_block_height + 1)..=result.blocks {
block_heights_to_scan.push_back(entry);
}
}
Expand Down

0 comments on commit c31611f

Please sign in to comment.