Skip to content

Commit

Permalink
fix: update scan status for non-triggering predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
MicaiahReid committed Mar 1, 2024
1 parent 384f94a commit d7a5c3d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
28 changes: 14 additions & 14 deletions components/chainhook-cli/src/scan/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
let http_client = build_http_client();

while let Some(current_block_height) = block_heights_to_scan.pop_front() {
if let Some(ref mut predicates_db_conn) = predicates_db_conn {
if number_of_blocks_scanned % 10 == 0 || number_of_blocks_scanned == 0 {
set_predicate_scanning_status(
&predicate_spec.key(),
number_of_blocks_to_scan,
number_of_blocks_scanned,
number_of_times_triggered,
current_block_height,
predicates_db_conn,
ctx,
);
}
}

if current_block_height > chain_tip {
let prev_chain_tip = chain_tip;
// we've scanned up to the chain tip as of the start of this scan
Expand Down Expand Up @@ -182,20 +196,6 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
return Err(format!("Scan aborted (consecutive action errors >= 3)"));
}
}

if let Some(ref mut predicates_db_conn) = predicates_db_conn {
if number_of_blocks_scanned % 10 == 0 || number_of_blocks_scanned == 1 {
set_predicate_scanning_status(
&predicate_spec.key(),
number_of_blocks_to_scan,
number_of_blocks_scanned,
number_of_times_triggered,
current_block_height,
predicates_db_conn,
ctx,
);
}
}
}

info!(
Expand Down
28 changes: 14 additions & 14 deletions components/chainhook-cli/src/scan/stacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ pub async fn scan_stacks_chainstate_via_rocksdb_using_predicate(
};

while let Some(current_block_height) = block_heights_to_scan.pop_front() {
if let Some(ref mut predicates_db_conn) = predicates_db_conn {
if number_of_blocks_scanned % 10 == 0 || number_of_blocks_scanned == 0 {
set_predicate_scanning_status(
&predicate_spec.key(),
number_of_blocks_to_scan,
number_of_blocks_scanned,
number_of_times_triggered,
current_block_height,
predicates_db_conn,
ctx,
);
}
}
if current_block_height > chain_tip {
let prev_chain_tip = chain_tip;
// we've scanned up to the chain tip as of the start of this scan
Expand Down Expand Up @@ -279,6 +292,7 @@ pub async fn scan_stacks_chainstate_via_rocksdb_using_predicate(

let (hits_per_blocks, _predicates_expired) =
evaluate_stacks_chainhook_on_blocks(blocks, &predicate_spec, ctx);

if hits_per_blocks.is_empty() {
continue;
}
Expand Down Expand Up @@ -325,20 +339,6 @@ pub async fn scan_stacks_chainstate_via_rocksdb_using_predicate(
return Err(format!("Scan aborted (consecutive action errors >= 3)"));
}
}

if let Some(ref mut predicates_db_conn) = predicates_db_conn {
if number_of_blocks_scanned % 10 == 0 || number_of_blocks_scanned == 1 {
set_predicate_scanning_status(
&predicate_spec.key(),
number_of_blocks_to_scan,
number_of_blocks_scanned,
number_of_times_triggered,
current_block_height,
predicates_db_conn,
ctx,
);
}
}
}
info!(
ctx.expect_logger(),
Expand Down

0 comments on commit d7a5c3d

Please sign in to comment.