fix: adjust error message

This commit is contained in:
Ludo Galabru
2023-06-07 19:44:54 -04:00
parent 2b51dca8f3
commit 3e7b0d03f9
3 changed files with 19 additions and 14 deletions

View File

@@ -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(),

View File

@@ -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(
@@ -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;

View File

@@ -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);
}
};