Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

fix: added a timeout #159

Merged
merged 2 commits into from
Mar 11, 2024
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
12 changes: 8 additions & 4 deletions src/indexer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::config::IndexerConfig;
use crate::utils::load_checksums;
use futures::stream::StreamExt;
use futures_util::pin_mut;
use futures_util::Stream;
Expand All @@ -12,11 +14,9 @@ use tendermint_rpc::{self, Client, HttpClient};
use tokio::sync::mpsc::Receiver;
use tokio::sync::mpsc::Sender;
use tokio::task::JoinHandle;
use tokio::time::timeout;
use tracing::{info, instrument};

use crate::config::IndexerConfig;
use crate::utils::load_checksums;

pub mod utils;

use super::database::Database;
Expand Down Expand Up @@ -156,7 +156,11 @@ fn blocks_stream(
block: u64,
client: &HttpClient,
) -> impl Stream<Item = (Block, block_results::Response)> + '_ {
futures::stream::iter(block..).then(move |i| async move { get_block(i as u32, client).await })
futures::stream::iter(block..).then(move |i| async move {
timeout(Duration::from_secs(30), get_block(i as u32, client))
.await
.unwrap()
})
}

/// Start the indexer service blocking current thread.
Expand Down
Loading