File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ pub mod subgraph;
8
8
use clap:: Parser ;
9
9
use contracts:: Contracts ;
10
10
use json_oracle_encoder:: { print_encoded_json_messages, OutputKind } ;
11
+ use reqwest:: Client ;
11
12
use std:: path:: PathBuf ;
13
+ use std:: time:: Duration ;
12
14
use web3:: transports:: Http ;
13
15
14
16
pub use config:: Config ;
@@ -104,7 +106,11 @@ async fn print_current_epoch(config: Config) -> anyhow::Result<()> {
104
106
}
105
107
106
108
fn init_contracts ( config : Config ) -> anyhow:: Result < Contracts < Http > > {
107
- let transport = Http :: new ( config. protocol_chain . jrpc_url . as_str ( ) ) ?;
109
+ let client = Client :: builder ( )
110
+ . timeout ( Duration :: from_secs ( 60 ) )
111
+ . build ( )
112
+ . unwrap ( ) ;
113
+ let transport = Http :: with_client ( client, config. protocol_chain . jrpc_url ) ;
108
114
let protocol_chain = JrpcProviderForChain :: new ( config. protocol_chain . id , transport) ;
109
115
Contracts :: new (
110
116
protocol_chain. web3 ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use futures::{
8
8
FutureExt ,
9
9
} ;
10
10
use jsonrpc_core:: { Call , Value } ;
11
+ use reqwest:: Client ;
11
12
use serde:: { Deserialize , Serialize } ;
12
13
use std:: collections:: BTreeMap ;
13
14
use std:: ops:: RangeInclusive ;
@@ -43,9 +44,12 @@ impl<T> JrpcExpBackoff<T> {
43
44
44
45
impl JrpcExpBackoff {
45
46
pub fn http ( jrpc_url : Url , network : Caip2ChainId , max_wait : Duration ) -> Self {
46
- // Unwrap: URLs were already parsed and are valid.
47
- let client = Http :: new ( jrpc_url. as_str ( ) ) . expect ( "failed to create HTTP transport" ) ;
48
- Self :: new ( client, network, max_wait)
47
+ let client = Client :: builder ( )
48
+ . timeout ( Duration :: from_secs ( 60 ) )
49
+ . build ( )
50
+ . unwrap ( ) ;
51
+ let transport = Http :: with_client ( client, jrpc_url) ;
52
+ Self :: new ( transport, network, max_wait)
49
53
}
50
54
}
51
55
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use anyhow::ensure;
5
5
use graphql_client:: { GraphQLQuery , Response } ;
6
6
use itertools:: Itertools ;
7
7
use reqwest:: Url ;
8
+ use std:: time:: Duration ;
8
9
use tracing:: { error, info, warn} ;
9
10
10
11
#[ derive( Debug , thiserror:: Error ) ]
@@ -41,6 +42,7 @@ pub async fn query_subgraph(
41
42
info ! ( "Fetching latest subgraph state" ) ;
42
43
43
44
let client = reqwest:: Client :: builder ( )
45
+ . timeout ( Duration :: from_secs ( 60 ) )
44
46
. user_agent ( "block-oracle" )
45
47
. build ( )
46
48
. unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments