@@ -46,7 +46,8 @@ use crate::{
4646 tap:: IndexerTapContext ,
4747} ;
4848
49- use super :: { request_handler:: request_handler, IndexerServiceConfig } ;
49+ use super :: request_handler:: request_handler;
50+ use indexer_config:: Config ;
5051
5152pub trait IndexerServiceResponse {
5253 type Data : IntoResponse ;
@@ -172,7 +173,7 @@ where
172173 I : IndexerServiceImpl + Sync + Send + ' static ,
173174{
174175 pub service_impl : I ,
175- pub config : IndexerServiceConfig ,
176+ pub config : Config ,
176177 pub release : IndexerServiceRelease ,
177178 pub url_namespace : & ' static str ,
178179 pub extra_routes : Router < Arc < IndexerServiceState < I > > > ,
@@ -182,7 +183,7 @@ pub struct IndexerServiceState<I>
182183where
183184 I : IndexerServiceImpl + Sync + Send + ' static ,
184185{
185- pub config : IndexerServiceConfig ,
186+ pub config : Config ,
186187 pub attestation_signers : Receiver < HashMap < Address , AttestationSigner > > ,
187188 pub tap_manager : Manager < IndexerTapContext > ,
188189 pub service_impl : Arc < I > ,
@@ -211,7 +212,7 @@ impl IndexerService {
211212 . config
212213 . graph_node
213214 . as_ref ( )
214- . zip ( options. config . network_subgraph . deployment )
215+ . zip ( options. config . subgraphs . network . config . deployment_id )
215216 . map ( |( graph_node, deployment) | {
216217 DeploymentDetails :: for_graph_node (
217218 & graph_node. status_url ,
@@ -221,8 +222,20 @@ impl IndexerService {
221222 } )
222223 . transpose ( ) ?,
223224 DeploymentDetails :: for_query_url_with_token (
224- & options. config . network_subgraph . query_url ,
225- options. config . network_subgraph . query_auth_token . clone ( ) ,
225+ & options
226+ . config
227+ . subgraphs
228+ . network
229+ . config
230+ . query_url
231+ . to_string ( ) ,
232+ options
233+ . config
234+ . subgraphs
235+ . network
236+ . config
237+ . query_auth_token
238+ . clone ( ) ,
226239 ) ?,
227240 ) ) ) ;
228241
@@ -233,21 +246,31 @@ impl IndexerService {
233246 let allocations = indexer_allocations (
234247 network_subgraph,
235248 options. config . indexer . indexer_address ,
236- Duration :: from_secs ( options. config . network_subgraph . syncing_interval ) ,
237249 Duration :: from_secs (
238250 options
239251 . config
240- . network_subgraph
241- . recently_closed_allocation_buffer_seconds ,
252+ . subgraphs
253+ . network
254+ . config
255+ . syncing_interval_secs
256+ . as_secs ( ) ,
257+ ) ,
258+ Duration :: from_secs (
259+ options
260+ . config
261+ . subgraphs
262+ . network
263+ . recently_closed_allocation_buffer_secs
264+ . as_secs ( ) ,
242265 ) ,
243266 ) ;
244267
245268 // Maintain an up-to-date set of attestation signers, one for each
246269 // allocation
247270 let attestation_signers = attestation_signers (
248271 allocations. clone ( ) ,
249- options. config . indexer . operator_mnemonic . clone ( ) ,
250- options. config . graph_network . chain_id ,
272+ options. config . indexer . operator_mnemonic . to_string ( ) ,
273+ options. config . blockchain . chain_id as u64 ,
251274 dispute_manager,
252275 )
253276 . await ;
@@ -258,7 +281,7 @@ impl IndexerService {
258281 . config
259282 . graph_node
260283 . as_ref ( )
261- . zip ( options. config . escrow_subgraph . deployment )
284+ . zip ( options. config . subgraphs . escrow . config . deployment_id )
262285 . map ( |( graph_node, deployment) | {
263286 DeploymentDetails :: for_graph_node (
264287 & graph_node. status_url ,
@@ -268,15 +291,29 @@ impl IndexerService {
268291 } )
269292 . transpose ( ) ?,
270293 DeploymentDetails :: for_query_url_with_token (
271- & options. config . escrow_subgraph . query_url ,
272- options. config . escrow_subgraph . query_auth_token . clone ( ) ,
294+ & options. config . subgraphs . escrow . config . query_url . to_string ( ) ,
295+ options
296+ . config
297+ . subgraphs
298+ . escrow
299+ . config
300+ . query_auth_token
301+ . clone ( ) ,
273302 ) ?,
274303 ) ) ) ;
275304
276305 let escrow_accounts = escrow_accounts (
277306 escrow_subgraph,
278307 options. config . indexer . indexer_address ,
279- Duration :: from_secs ( options. config . escrow_subgraph . syncing_interval ) ,
308+ Duration :: from_secs (
309+ options
310+ . config
311+ . subgraphs
312+ . escrow
313+ . config
314+ . syncing_interval_secs
315+ . as_secs ( ) ,
316+ ) ,
280317 true , // Reject thawing signers eagerly
281318 ) ;
282319
@@ -290,19 +327,31 @@ impl IndexerService {
290327 let database = PgPoolOptions :: new ( )
291328 . max_connections ( 50 )
292329 . acquire_timeout ( Duration :: from_secs ( 30 ) )
293- . connect ( & options. config . database . postgres_url )
330+ . connect (
331+ & options
332+ . config
333+ . database
334+ . get_formated_postgres_url ( )
335+ . to_string ( ) ,
336+ )
294337 . await ?;
295338
296339 let domain_separator = tap_eip712_domain (
297- options. config . tap . chain_id ,
298- options. config . tap . receipts_verifier_address ,
340+ options. config . blockchain . chain_id as u64 ,
341+ options. config . blockchain . receipts_verifier_address ,
299342 ) ;
300343 let indexer_context =
301344 IndexerTapContext :: new ( database. clone ( ) , domain_separator. clone ( ) ) . await ;
302- let timestamp_error_tolerance =
303- Duration :: from_secs ( options. config . tap . timestamp_error_tolerance ) ;
345+ let timestamp_error_tolerance = Duration :: from_secs (
346+ options
347+ . config
348+ . tap
349+ . rav_request
350+ . timestamp_buffer_secs
351+ . as_secs ( ) ,
352+ ) ;
304353
305- let receipt_max_value = options. config . tap . receipt_max_value ;
354+ let receipt_max_value = options. config . service . tap . max_receipt_value_grt . get_value ( ) ;
306355
307356 let checks = IndexerTapContext :: get_checks (
308357 database,
@@ -343,7 +392,7 @@ impl IndexerService {
343392 } ;
344393
345394 let operator_address = Json (
346- serde_json:: json!( { "publicKey" : public_key( & options. config. indexer. operator_mnemonic) ?} ) ,
395+ serde_json:: json!( { "publicKey" : public_key( & options. config. indexer. operator_mnemonic. to_string ( ) ) ?} ) ,
347396 ) ;
348397
349398 let mut misc_routes = Router :: new ( )
@@ -365,37 +414,33 @@ impl IndexerService {
365414 ) ) ,
366415 } ;
367416
368- if options. config . network_subgraph . serve_subgraph {
417+ if options. config . service . serve_network_subgraph {
369418 info ! ( "Serving network subgraph at /network" ) ;
370419
371420 misc_routes = misc_routes. route (
372421 "/network" ,
373422 post ( static_subgraph_request_handler :: < I > )
374423 . route_layer ( Extension ( network_subgraph) )
375- . route_layer ( Extension (
376- options. config . network_subgraph . serve_auth_token . clone ( ) ,
377- ) )
424+ . route_layer ( Extension ( options. config . service . serve_auth_token . clone ( ) ) )
378425 . route_layer ( static_subgraph_rate_limiter. clone ( ) ) ,
379426 ) ;
380427 }
381428
382- if options. config . escrow_subgraph . serve_subgraph {
429+ if options. config . service . serve_escrow_subgraph {
383430 info ! ( "Serving escrow subgraph at /escrow" ) ;
384431
385432 misc_routes = misc_routes
386433 . route ( "/escrow" , post ( static_subgraph_request_handler :: < I > ) )
387434 . route_layer ( Extension ( escrow_subgraph) )
388- . route_layer ( Extension (
389- options. config . escrow_subgraph . serve_auth_token . clone ( ) ,
390- ) )
435+ . route_layer ( Extension ( options. config . service . serve_auth_token . clone ( ) ) )
391436 . route_layer ( static_subgraph_rate_limiter) ;
392437 }
393438
394439 misc_routes = misc_routes. with_state ( state. clone ( ) ) ;
395440
396441 let data_routes = Router :: new ( )
397442 . route (
398- PathBuf :: from ( options. config . server . url_prefix )
443+ PathBuf :: from ( options. config . service . url_prefix )
399444 . join ( format ! ( "{}/id/:id" , options. url_namespace) )
400445 . to_str ( )
401446 . expect ( "Failed to set up `/{url_namespace}/id/:id` route" ) ,
@@ -443,10 +488,10 @@ impl IndexerService {
443488 Self :: serve_metrics ( options. config . server . metrics_host_and_port ) ;
444489
445490 info ! (
446- address = %options. config. server . host_and_port,
491+ address = %options. config. service . host_and_port,
447492 "Serving requests" ,
448493 ) ;
449- let listener = TcpListener :: bind ( & options. config . server . host_and_port )
494+ let listener = TcpListener :: bind ( & options. config . service . host_and_port )
450495 . await
451496 . expect ( "Failed to bind to indexer-service port" ) ;
452497
0 commit comments