Skip to content

Commit

Permalink
fix: adjust error message
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Jun 7, 2023
1 parent 2b51dca commit 3e7b0d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion components/chainhook-cli/src/service/mod.rs
Expand Up @@ -51,7 +51,7 @@ impl Service {
};
for (predicate, _status) in registered_predicates.into_iter() {
let predicate_uuid = predicate.uuid().to_string();
match chainhook_config.register_specification(predicate, true) {
match chainhook_config.register_specification(predicate) {
Ok(_) => {
info!(
self.ctx.expect_logger(),
Expand Down
19 changes: 15 additions & 4 deletions components/chainhook-cli/src/service/runloops.rs
Expand Up @@ -15,7 +15,10 @@ use crate::{
bitcoin::scan_bitcoin_chainstate_via_rpc_using_predicate,
stacks::scan_stacks_chainstate_via_rocksdb_using_predicate,
},
storage::open_readonly_stacks_db_conn, service::{PredicateStatus, update_predicate_status, open_readwrite_predicates_db_conn_or_panic},
service::{
open_readwrite_predicates_db_conn_or_panic, update_predicate_status, PredicateStatus,
},
storage::open_readonly_stacks_db_conn,
};

pub fn start_stacks_scan_runloop(
Expand Down Expand Up @@ -61,9 +64,17 @@ pub fn start_stacks_scan_runloop(

// 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);
let status = PredicateStatus::Interrupted(format!(
"Unable to evaluate predicate on Stacks chainstate: {e}"
));
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;
Expand Down
12 changes: 3 additions & 9 deletions components/chainhook-event-observer/src/chainhooks/types.rs
Expand Up @@ -85,20 +85,14 @@ impl ChainhookConfig {
};
}

pub fn register_specification(
&mut self,
spec: ChainhookSpecification,
enabled: bool,
) -> Result<(), String> {
pub fn register_specification(&mut self, spec: ChainhookSpecification) -> Result<(), String> {
match spec {
ChainhookSpecification::Stacks(spec) => {
let mut spec = spec.clone();
spec.enabled = enabled;
let spec = spec.clone();
self.stacks_chainhooks.push(spec);
}
ChainhookSpecification::Bitcoin(spec) => {
let mut spec = spec.clone();
spec.enabled = enabled;
let spec = spec.clone();
self.bitcoin_chainhooks.push(spec);
}
};
Expand Down

0 comments on commit 3e7b0d0

Please sign in to comment.