Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/hermes/server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/hermes/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hermes"
version = "0.10.1-alpha"
version = "0.10.2-alpha"
description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
edition = "2021"

Expand Down
3 changes: 2 additions & 1 deletion apps/hermes/server/src/config/pythnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ pub struct Options {
/// Address of a PythNet quorum websocket RPC endpoint.
#[arg(long = "pythnet-quorum-ws-addr")]
#[arg(env = "PYTHNET_QUORUM_WS_ADDR")]
pub quorum_ws_addr: Option<String>,
#[arg(value_delimiter = ',')]
pub quorum_ws_addrs: Option<Vec<String>>,
}
42 changes: 22 additions & 20 deletions apps/hermes/server/src/network/pythnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,27 +436,29 @@ where
})
};

let task_quorum_listener = match opts.pythnet.quorum_ws_addr {
Some(pythnet_quorum_ws_addr) => {
let store = state.clone();
let mut exit = crate::EXIT.subscribe();
tokio::spawn(async move {
loop {
let current_time = Instant::now();
tokio::select! {
_ = exit.changed() => break,
Err(err) = run_quorom_listener(store.clone(), pythnet_quorum_ws_addr.clone()) => {
tracing::error!(error = ?err, "Error in Pythnet quorum network listener.");
if current_time.elapsed() < Duration::from_secs(30) {
tracing::error!("Pythnet quorum listener restarting too quickly. Sleep 1s.");
tokio::time::sleep(Duration::from_secs(1)).await;
let task_quorum_listeners = match opts.pythnet.quorum_ws_addrs {
Some(pythnet_quorum_ws_addrs) => tokio::spawn(async move {
pythnet_quorum_ws_addrs.into_iter().for_each(|pythnet_quorum_ws_addr| {
let store = state.clone();
let mut exit = crate::EXIT.subscribe();
tokio::spawn(async move {
loop {
let current_time = Instant::now();
tokio::select! {
_ = exit.changed() => break,
Err(err) = run_quorom_listener(store.clone(), pythnet_quorum_ws_addr.clone()) => {
tracing::error!(error = ?err, "Error in Pythnet quorum network listener.");
if current_time.elapsed() < Duration::from_secs(30) {
tracing::error!("Pythnet quorum listener restarting too quickly. Sleep 1s.");
tokio::time::sleep(Duration::from_secs(1)).await;
}
}
}
}
}
}
tracing::info!("Shutting down Pythnet quorum listener...");
})
}
tracing::info!("Shutting down Pythnet quorum listener...");
});
});
}),
None => tokio::spawn(async {
tracing::warn!(
"Pythnet quorum websocket address not provided, skipping quorum listener."
Expand All @@ -468,7 +470,7 @@ where
task_listener,
task_guardian_watcher,
task_price_feeds_metadata_updater,
task_quorum_listener,
task_quorum_listeners,
);
Ok(())
}
Expand Down
Loading