Skip to content

Commit 3e7b0d0

Browse files
author
Ludo Galabru
committed
fix: adjust error message
1 parent 2b51dca commit 3e7b0d0

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

components/chainhook-cli/src/service/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Service {
5151
};
5252
for (predicate, _status) in registered_predicates.into_iter() {
5353
let predicate_uuid = predicate.uuid().to_string();
54-
match chainhook_config.register_specification(predicate, true) {
54+
match chainhook_config.register_specification(predicate) {
5555
Ok(_) => {
5656
info!(
5757
self.ctx.expect_logger(),

components/chainhook-cli/src/service/runloops.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ use crate::{
1515
bitcoin::scan_bitcoin_chainstate_via_rpc_using_predicate,
1616
stacks::scan_stacks_chainstate_via_rocksdb_using_predicate,
1717
},
18-
storage::open_readonly_stacks_db_conn, service::{PredicateStatus, update_predicate_status, open_readwrite_predicates_db_conn_or_panic},
18+
service::{
19+
open_readwrite_predicates_db_conn_or_panic, update_predicate_status, PredicateStatus,
20+
},
21+
storage::open_readonly_stacks_db_conn,
1922
};
2023

2124
pub fn start_stacks_scan_runloop(
@@ -61,9 +64,17 @@ pub fn start_stacks_scan_runloop(
6164

6265
// Update predicate status in redis
6366
if let PredicatesApi::On(ref api_config) = moved_config.http_api {
64-
let status = PredicateStatus::Interrupted("Unable to evaluate predicate on Stacks chainstate: {e}".to_string());
65-
let mut predicates_db_conn = open_readwrite_predicates_db_conn_or_panic(api_config, &moved_ctx);
66-
update_predicate_status(&predicate_spec.key(), status, &mut predicates_db_conn, &moved_ctx);
67+
let status = PredicateStatus::Interrupted(format!(
68+
"Unable to evaluate predicate on Stacks chainstate: {e}"
69+
));
70+
let mut predicates_db_conn =
71+
open_readwrite_predicates_db_conn_or_panic(api_config, &moved_ctx);
72+
update_predicate_status(
73+
&predicate_spec.key(),
74+
status,
75+
&mut predicates_db_conn,
76+
&moved_ctx,
77+
);
6778
}
6879

6980
return;

components/chainhook-event-observer/src/chainhooks/types.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,14 @@ impl ChainhookConfig {
8585
};
8686
}
8787

88-
pub fn register_specification(
89-
&mut self,
90-
spec: ChainhookSpecification,
91-
enabled: bool,
92-
) -> Result<(), String> {
88+
pub fn register_specification(&mut self, spec: ChainhookSpecification) -> Result<(), String> {
9389
match spec {
9490
ChainhookSpecification::Stacks(spec) => {
95-
let mut spec = spec.clone();
96-
spec.enabled = enabled;
91+
let spec = spec.clone();
9792
self.stacks_chainhooks.push(spec);
9893
}
9994
ChainhookSpecification::Bitcoin(spec) => {
100-
let mut spec = spec.clone();
101-
spec.enabled = enabled;
95+
let spec = spec.clone();
10296
self.bitcoin_chainhooks.push(spec);
10397
}
10498
};

0 commit comments

Comments
 (0)