Przeglądaj źródła

fix(hermes): ignore no subscriber error on broadcast (#1492)

This change ignores the errors appearing when there are
no subsribers to price updates. The issue was fixed before
and was missed during the refactor.
Ali Behjati 1 rok temu
rodzic
commit
64037e5b4a
3 zmienionych plików z 12 dodań i 12 usunięć
  1. 1 1
      apps/hermes/Cargo.lock
  2. 1 1
      apps/hermes/Cargo.toml
  3. 10 10
      apps/hermes/src/state/aggregate.rs

+ 1 - 1
apps/hermes/Cargo.lock

@@ -1796,7 +1796,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
 
 [[package]]
 name = "hermes"
-version = "0.5.6"
+version = "0.5.7"
 dependencies = [
  "anyhow",
  "async-trait",

+ 1 - 1
apps/hermes/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name        = "hermes"
-version     = "0.5.6"
+version     = "0.5.7"
 description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
 edition     = "2021"
 

+ 10 - 10
apps/hermes/src/state/aggregate.rs

@@ -323,27 +323,27 @@ where
         // Update the aggregate state
         let mut aggregate_state = self.into().data.write().await;
 
-        // Check if the update is new or out of order
-        match aggregate_state.latest_completed_slot {
+        // Send update event to subscribers. We are purposefully ignoring the result
+        // because there might be no subscribers.
+        let _ = match aggregate_state.latest_completed_slot {
             None => {
                 aggregate_state.latest_completed_slot.replace(slot);
                 self.into()
                     .api_update_tx
-                    .send(AggregationEvent::New { slot })?;
+                    .send(AggregationEvent::New { slot })
             }
             Some(latest) if slot > latest => {
                 self.prune_removed_keys(message_state_keys).await;
                 aggregate_state.latest_completed_slot.replace(slot);
                 self.into()
                     .api_update_tx
-                    .send(AggregationEvent::New { slot })?;
+                    .send(AggregationEvent::New { slot })
             }
-            _ => {
-                self.into()
-                    .api_update_tx
-                    .send(AggregationEvent::OutOfOrder { slot })?;
-            }
-        }
+            _ => self
+                .into()
+                .api_update_tx
+                .send(AggregationEvent::OutOfOrder { slot }),
+        };
 
         aggregate_state.latest_completed_slot = aggregate_state
             .latest_completed_slot