Skip to content

Commit e268925

Browse files
author
Ludo Galabru
committed
fix: update spec status
1 parent d4889f1 commit e268925

File tree

2 files changed

+11
-1
lines changed
  • components

2 files changed

+11
-1
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ impl Service {
253253
ObserverEvent::PredicateEnabled(spec) => {
254254
if let Some(ref mut predicates_db_conn) = predicates_db_conn {
255255
update_predicate_spec(&spec.key(), &spec, predicates_db_conn, &self.ctx);
256+
update_predicate_status(
257+
&spec.key(),
258+
PredicateStatus::InitialScanCompleted,
259+
predicates_db_conn,
260+
&self.ctx,
261+
);
256262
}
257263
}
258264
ObserverEvent::PredicateDeregistered(chainhook) => {
@@ -311,6 +317,7 @@ impl Service {
311317
};
312318

313319
for (predicate_uuid, blocks_ids) in report.predicates_evaluated.iter() {}
320+
314321
for (predicate_uuid, blocks_ids) in report.predicates_triggered.iter() {}
315322
// Every 32 blocks, we will check if there's a new Stacks file archive to ingest
316323
if stacks_event > 32 {
@@ -338,6 +345,7 @@ impl Service {
338345
pub enum PredicateStatus {
339346
Scanning(ScanningData),
340347
Streaming(StreamingData),
348+
InitialScanCompleted,
341349
Interrupted(String),
342350
Disabled,
343351
}

components/chainhook-sdk/src/chainhooks/types.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ impl ChainhookConfig {
6464
Ok(spec)
6565
}
6666

67-
pub fn enable_specification(&mut self, predicate_spec: &ChainhookSpecification) {
67+
pub fn enable_specification(&mut self, predicate_spec: &mut ChainhookSpecification) {
6868
match predicate_spec {
6969
ChainhookSpecification::Stacks(spec_to_enable) => {
7070
for spec in self.stacks_chainhooks.iter_mut() {
7171
if spec.uuid.eq(&spec_to_enable.uuid) {
7272
spec.enabled = true;
73+
spec_to_enable.enabled = true;
7374
break;
7475
}
7576
}
@@ -78,6 +79,7 @@ impl ChainhookConfig {
7879
for spec in self.bitcoin_chainhooks.iter_mut() {
7980
if spec.uuid.eq(&spec_to_enable.uuid) {
8081
spec.enabled = true;
82+
spec_to_enable.enabled = true;
8183
break;
8284
}
8385
}

0 commit comments

Comments
 (0)