mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-04-30 20:51:51 +08:00
fix: off by one
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user