@@ -17,9 +17,9 @@ use indexer_config::{
1717 ServiceConfig , ServiceTapConfig ,
1818} ;
1919use indexer_monitor:: {
20- attestation_signers, deployment_to_allocation, dispute_manager, escrow_accounts ,
21- indexer_allocations, AllocationWatcher , DisputeManagerWatcher , EscrowAccountsWatcher ,
22- SubgraphClient ,
20+ attestation_signers, deployment_to_allocation, dispute_manager, escrow_accounts_v1 ,
21+ escrow_accounts_v2 , indexer_allocations, AllocationWatcher , DisputeManagerWatcher ,
22+ EscrowAccountsWatcher , SubgraphClient ,
2323} ;
2424use reqwest:: Method ;
2525use tap_core:: { manager:: Manager , receipt:: checks:: CheckList } ;
@@ -34,7 +34,6 @@ use tower_http::{
3434 trace:: TraceLayer ,
3535 validate_request:: ValidateRequestHeaderLayer ,
3636} ;
37- use typed_builder:: TypedBuilder ;
3837
3938use super :: { release:: IndexerServiceRelease , GraphNodeState } ;
4039use crate :: {
@@ -51,7 +50,7 @@ use crate::{
5150 wallet:: public_key,
5251} ;
5352
54- #[ derive( TypedBuilder ) ]
53+ #[ derive( bon :: Builder ) ]
5554pub struct ServiceRouter {
5655 // database
5756 database : sqlx:: PgPool ,
@@ -60,7 +59,6 @@ pub struct ServiceRouter {
6059 // graphnode client
6160 http_client : reqwest:: Client ,
6261 // release info
63- #[ builder( default , setter( strip_option) ) ]
6462 release : Option < IndexerServiceRelease > ,
6563
6664 // configuration
@@ -71,23 +69,21 @@ pub struct ServiceRouter {
7169 timestamp_buffer_secs : Duration ,
7270
7371 // either provide subgraph or watcher
74- #[ builder( default , setter ( transform =
72+ #[ builder( with =
7573 |subgraph: & ' static SubgraphClient ,
76- config: EscrowSubgraphConfig |
77- Some ( ( subgraph, config) ) ) ) ]
74+ config: EscrowSubgraphConfig |
75+ ( subgraph, config) ) ]
7876 escrow_subgraph : Option < ( & ' static SubgraphClient , EscrowSubgraphConfig ) > ,
79- #[ builder( default , setter( strip_option) ) ]
80- escrow_accounts : Option < EscrowAccountsWatcher > ,
77+ escrow_accounts_v1 : Option < EscrowAccountsWatcher > ,
78+
79+ escrow_accounts_v2 : Option < EscrowAccountsWatcher > ,
8180
8281 // provide network subgraph or allocations + dispute manager
83- #[ builder( default , setter( transform =
84- |subgraph: & ' static SubgraphClient ,
85- config: NetworkSubgraphConfig |
86- Some ( ( subgraph, config) ) ) ) ]
82+ #[ builder( with = |subgraph: & ' static SubgraphClient ,
83+ config: NetworkSubgraphConfig |
84+ ( subgraph, config) ) ]
8785 network_subgraph : Option < ( & ' static SubgraphClient , NetworkSubgraphConfig ) > ,
88- #[ builder( default , setter( strip_option) ) ]
8986 allocations : Option < AllocationWatcher > ,
90- #[ builder( default , setter( strip_option) ) ]
9187 dispute_manager : Option < DisputeManagerWatcher > ,
9288}
9389
@@ -141,11 +137,26 @@ impl ServiceRouter {
141137 ( None , None ) => panic ! ( "No allocations or network subgraph was provided" ) ,
142138 } ;
143139
144- // Monitor escrow accounts
140+ // Monitor escrow accounts v1
141+ // if not provided, create monitor from subgraph
142+ let escrow_accounts_v1 = match ( self . escrow_accounts_v1 , self . escrow_subgraph . as_ref ( ) ) {
143+ ( Some ( escrow_account) , _) => escrow_account,
144+ ( _, Some ( ( escrow_subgraph, escrow) ) ) => escrow_accounts_v1 (
145+ escrow_subgraph,
146+ indexer_address,
147+ escrow. config . syncing_interval_secs ,
148+ true , // Reject thawing signers eagerly
149+ )
150+ . await
151+ . expect ( "Error creating escrow_accounts channel" ) ,
152+ ( None , None ) => panic ! ( "No escrow accounts or escrow subgraph was provided" ) ,
153+ } ;
154+
155+ // Monitor escrow accounts v2
145156 // if not provided, create monitor from subgraph
146- let escrow_accounts = match ( self . escrow_accounts , self . escrow_subgraph . as_ref ( ) ) {
157+ let escrow_accounts_v2 = match ( self . escrow_accounts_v2 , self . escrow_subgraph . as_ref ( ) ) {
147158 ( Some ( escrow_account) , _) => escrow_account,
148- ( _, Some ( ( escrow_subgraph, escrow) ) ) => escrow_accounts (
159+ ( _, Some ( ( escrow_subgraph, escrow) ) ) => escrow_accounts_v2 (
149160 escrow_subgraph,
150161 indexer_address,
151162 escrow. config . syncing_interval_secs ,
@@ -255,7 +266,8 @@ impl ServiceRouter {
255266 let checks = IndexerTapContext :: get_checks (
256267 self . database ,
257268 allocations. clone ( ) ,
258- escrow_accounts. clone ( ) ,
269+ escrow_accounts_v1. clone ( ) ,
270+ escrow_accounts_v2. clone ( ) ,
259271 timestamp_error_tolerance,
260272 receipt_max_value,
261273 )
@@ -299,7 +311,8 @@ impl ServiceRouter {
299311 deployment_to_allocation,
300312 } ;
301313 let sender_state = SenderState {
302- escrow_accounts,
314+ escrow_accounts_v1,
315+ escrow_accounts_v2,
303316 domain_separator : self . domain_separator ,
304317 } ;
305318
0 commit comments