fix: off by one

This commit is contained in:
Ludo Galabru
2023-08-03 05:34:59 +02:00
parent 0e3faf9a61
commit c31611fb28
2 changed files with 3 additions and 3 deletions

View File

@@ -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()));
}

View File

@@ -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 ({})",
@@ -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);
}
}