mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 22:43:06 +08:00
fix: track interrupted scans
This commit is contained in:
@@ -337,6 +337,7 @@ impl Service {
|
||||
pub enum PredicateStatus {
|
||||
Scanning(ScanningData),
|
||||
Streaming(StreamingData),
|
||||
Interrupted(String),
|
||||
Disabled,
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ use chainhook_event_observer::{
|
||||
use threadpool::ThreadPool;
|
||||
|
||||
use crate::{
|
||||
config::Config,
|
||||
config::{Config, PredicatesApi},
|
||||
scan::{
|
||||
bitcoin::scan_bitcoin_chainstate_via_rpc_using_predicate,
|
||||
stacks::scan_stacks_chainstate_via_rocksdb_using_predicate,
|
||||
},
|
||||
storage::open_readonly_stacks_db_conn,
|
||||
storage::open_readonly_stacks_db_conn, service::{PredicateStatus, update_predicate_status, open_readwrite_predicates_db_conn_or_panic},
|
||||
};
|
||||
|
||||
pub fn start_stacks_scan_runloop(
|
||||
@@ -50,13 +50,22 @@ pub fn start_stacks_scan_runloop(
|
||||
&moved_config,
|
||||
&moved_ctx,
|
||||
);
|
||||
let last_block_scanned = match hiro_system_kit::nestable_block_on(op) {
|
||||
let res = hiro_system_kit::nestable_block_on(op);
|
||||
let last_block_scanned = match res {
|
||||
Ok(last_block_scanned) => last_block_scanned,
|
||||
Err(e) => {
|
||||
error!(
|
||||
moved_ctx.expect_logger(),
|
||||
"Unable to evaluate predicate on Stacks chainstate: {e}",
|
||||
);
|
||||
|
||||
// Update predicate status in redis
|
||||
if let PredicatesApi::On(ref api_config) = moved_config.http_api {
|
||||
let status = PredicateStatus::Interrupted("Unable to evaluate predicate on Stacks chainstate: {e}".to_string());
|
||||
let mut predicates_db_conn = open_readwrite_predicates_db_conn_or_panic(api_config, &moved_ctx);
|
||||
update_predicate_status(&predicate_spec.key(), status, &mut predicates_db_conn, &moved_ctx);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user