Skip to content
Merged
Changes from all commits
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
20 changes: 18 additions & 2 deletions crates/networking/rpc/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ use tokio::sync::{
mpsc::{UnboundedSender, unbounded_channel},
oneshot,
};
use tokio::time::timeout;
use tower_http::cors::CorsLayer;
use tracing::{error, info};
use tracing::{error, info, warn};
use tracing_subscriber::{EnvFilter, Registry, reload};

#[cfg(all(feature = "jemalloc_profiling", target_os = "linux"))]
Expand Down Expand Up @@ -296,7 +297,22 @@ pub async fn start_api(
.into_future();
info!("Starting HTTP server at {http_addr}");

let authrpc_handler = |ctx, auth, body| async { handle_authrpc_request(ctx, auth, body).await };
let (timer_sender, mut timer_receiver) = tokio::sync::watch::channel(());

tokio::spawn(async move {
loop {
let result = timeout(Duration::from_secs(30), timer_receiver.changed()).await;
if result.is_err() {
warn!("No messages from the consensus layer. Is the consensus client running?");
}
}
});

let authrpc_handler = move |ctx, auth, body| async move {
let _ = timer_sender.send(());
handle_authrpc_request(ctx, auth, body).await
};

let authrpc_router = Router::new()
.route("/", post(authrpc_handler))
.with_state(service_context.clone())
Expand Down
Loading