From 62cdda36d0c4effb115b9fe168bc7bb0207b17d5 Mon Sep 17 00:00:00 2001 From: godmodegalactus Date: Thu, 14 Dec 2023 11:51:09 +0100 Subject: [PATCH] Adding timeout of 30s to resubscribe to blocks --- src/main.rs | 4 +++- src/postgres.rs | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index c4d650c..a52354b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -191,7 +191,9 @@ async fn start_tracking_blocks( ) .await .unwrap(); - while let Some(message) = geyser_stream.next().await { + while let Ok(Some(message)) = + tokio::time::timeout(Duration::from_secs(30), geyser_stream.next()).await + { let Ok(message) = message else { continue; }; diff --git a/src/postgres.rs b/src/postgres.rs index ae70f31..6df912e 100644 --- a/src/postgres.rs +++ b/src/postgres.rs @@ -735,9 +735,10 @@ impl Postgres { for batch in batches { if let Err(err) = session .save_banking_transaction_results(batch.to_vec()) - .await { - panic!("saving transaction infos failed {}", err); - } + .await + { + panic!("saving transaction infos failed {}", err); + } } } }