fix: update spec status

This commit is contained in:
Ludo Galabru
2023-06-08 14:25:01 -04:00
parent d4889f16b7
commit e2689255b7
2 changed files with 11 additions and 1 deletions

View File

@@ -253,6 +253,12 @@ impl Service {
ObserverEvent::PredicateEnabled(spec) => {
if let Some(ref mut predicates_db_conn) = predicates_db_conn {
update_predicate_spec(&spec.key(), &spec, predicates_db_conn, &self.ctx);
update_predicate_status(
&spec.key(),
PredicateStatus::InitialScanCompleted,
predicates_db_conn,
&self.ctx,
);
}
}
ObserverEvent::PredicateDeregistered(chainhook) => {
@@ -311,6 +317,7 @@ impl Service {
};
for (predicate_uuid, blocks_ids) in report.predicates_evaluated.iter() {}
for (predicate_uuid, blocks_ids) in report.predicates_triggered.iter() {}
// Every 32 blocks, we will check if there's a new Stacks file archive to ingest
if stacks_event > 32 {
@@ -338,6 +345,7 @@ impl Service {
pub enum PredicateStatus {
Scanning(ScanningData),
Streaming(StreamingData),
InitialScanCompleted,
Interrupted(String),
Disabled,
}

View File

@@ -64,12 +64,13 @@ impl ChainhookConfig {
Ok(spec)
}
pub fn enable_specification(&mut self, predicate_spec: &ChainhookSpecification) {
pub fn enable_specification(&mut self, predicate_spec: &mut ChainhookSpecification) {
match predicate_spec {
ChainhookSpecification::Stacks(spec_to_enable) => {
for spec in self.stacks_chainhooks.iter_mut() {
if spec.uuid.eq(&spec_to_enable.uuid) {
spec.enabled = true;
spec_to_enable.enabled = true;
break;
}
}
@@ -78,6 +79,7 @@ impl ChainhookConfig {
for spec in self.bitcoin_chainhooks.iter_mut() {
if spec.uuid.eq(&spec_to_enable.uuid) {
spec.enabled = true;
spec_to_enable.enabled = true;
break;
}
}