File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ pub struct Config {
4848 pub min_indexer_version : Version ,
4949 /// Indexers used to query the network subgraph
5050 pub trusted_indexers : Vec < TrustedIndexer > ,
51+ /// Maximum acceptable lag (in seconds) for network subgraph responses (default: 120)
52+ #[ serde( default = "default_network_subgraph_max_lag_seconds" ) ]
53+ pub network_subgraph_max_lag_seconds : u64 ,
5154 /// Check payment state of client (disable for testnets)
5255 pub payment_required : bool ,
5356 /// public API port
@@ -60,6 +63,11 @@ pub struct Config {
6063 pub receipts : Receipts ,
6164}
6265
66+ /// Default network subgraph max lag threshold (120 seconds)
67+ fn default_network_subgraph_max_lag_seconds ( ) -> u64 {
68+ 120
69+ }
70+
6371/// Deserialize a `NotNan<f64>` from a `f64` and return an error if the value is NaN.
6472fn deserialize_not_nan_f64 < ' de , D > ( deserializer : D ) -> Result < NotNan < f64 > , D :: Error >
6573where
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ async fn main() {
112112 indexers : conf. trusted_indexers ,
113113 latest_block : None ,
114114 page_size : 500 ,
115+ max_lag_seconds : conf. network_subgraph_max_lag_seconds ,
115116 } ;
116117 let indexer_host_blocklist = match & conf. ip_blocker_db {
117118 Some ( path) => {
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ pub struct Client {
125125 pub indexers : Vec < TrustedIndexer > ,
126126 pub page_size : usize ,
127127 pub latest_block : Option < Block > ,
128+ pub max_lag_seconds : u64 ,
128129}
129130
130131impl Client {
@@ -271,7 +272,8 @@ impl Client {
271272 "response block before latest" ,
272273 ) ;
273274 ensure ! (
274- ( unix_timestamp( ) / 1_000 ) . saturating_sub( block. timestamp) < 120 ,
275+ ( unix_timestamp( ) / 1_000 ) . saturating_sub( block. timestamp)
276+ < self . max_lag_seconds,
275277 "response too far behind" ,
276278 ) ;
277279 query_block = Some ( block) ;
You can’t perform that action at this time.
0 commit comments