Skip to content

Commit

Permalink
fix: consider end_block when scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Feb 5, 2024
1 parent 0416cd8 commit 2feb512
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions components/ordhook-core/src/scan/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,25 @@ 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 {
block_heights_to_scan.push_back(entry);
let new_tip = match bitcoin_rpc.get_blockchain_info() {
Ok(result) => match predicate_spec.end_block {
Some(end_block) => {
if end_block > result.blocks {
result.blocks
} else {
end_block
}
}
}
None => result.blocks,
},
Err(_e) => {
continue;
}
};

for entry in (current_block_height + 1)..new_tip {
block_heights_to_scan.push_back(entry);
}
}
}
info!(
Expand Down

0 comments on commit 2feb512

Please sign in to comment.