@@ -17,9 +17,9 @@ use indexer_config::{
17
17
ServiceConfig , ServiceTapConfig ,
18
18
} ;
19
19
use 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 ,
23
23
} ;
24
24
use reqwest:: Method ;
25
25
use tap_core:: { manager:: Manager , receipt:: checks:: CheckList } ;
@@ -34,7 +34,6 @@ use tower_http::{
34
34
trace:: TraceLayer ,
35
35
validate_request:: ValidateRequestHeaderLayer ,
36
36
} ;
37
- use typed_builder:: TypedBuilder ;
38
37
39
38
use super :: { release:: IndexerServiceRelease , GraphNodeState } ;
40
39
use crate :: {
@@ -51,7 +50,7 @@ use crate::{
51
50
wallet:: public_key,
52
51
} ;
53
52
54
- #[ derive( TypedBuilder ) ]
53
+ #[ derive( bon :: Builder ) ]
55
54
pub struct ServiceRouter {
56
55
// database
57
56
database : sqlx:: PgPool ,
@@ -60,7 +59,6 @@ pub struct ServiceRouter {
60
59
// graphnode client
61
60
http_client : reqwest:: Client ,
62
61
// release info
63
- #[ builder( default , setter( strip_option) ) ]
64
62
release : Option < IndexerServiceRelease > ,
65
63
66
64
// configuration
@@ -71,23 +69,21 @@ pub struct ServiceRouter {
71
69
timestamp_buffer_secs : Duration ,
72
70
73
71
// either provide subgraph or watcher
74
- #[ builder( default , setter ( transform =
72
+ #[ builder( with =
75
73
|subgraph: & ' static SubgraphClient ,
76
- config: EscrowSubgraphConfig |
77
- Some ( ( subgraph, config) ) ) ) ]
74
+ config: EscrowSubgraphConfig |
75
+ ( subgraph, config) ) ]
78
76
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 > ,
81
80
82
81
// 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) ) ]
87
85
network_subgraph : Option < ( & ' static SubgraphClient , NetworkSubgraphConfig ) > ,
88
- #[ builder( default , setter( strip_option) ) ]
89
86
allocations : Option < AllocationWatcher > ,
90
- #[ builder( default , setter( strip_option) ) ]
91
87
dispute_manager : Option < DisputeManagerWatcher > ,
92
88
}
93
89
@@ -141,11 +137,26 @@ impl ServiceRouter {
141
137
( None , None ) => panic ! ( "No allocations or network subgraph was provided" ) ,
142
138
} ;
143
139
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
145
156
// 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 ( ) ) {
147
158
( Some ( escrow_account) , _) => escrow_account,
148
- ( _, Some ( ( escrow_subgraph, escrow) ) ) => escrow_accounts (
159
+ ( _, Some ( ( escrow_subgraph, escrow) ) ) => escrow_accounts_v2 (
149
160
escrow_subgraph,
150
161
indexer_address,
151
162
escrow. config . syncing_interval_secs ,
@@ -255,7 +266,8 @@ impl ServiceRouter {
255
266
let checks = IndexerTapContext :: get_checks (
256
267
self . database ,
257
268
allocations. clone ( ) ,
258
- escrow_accounts. clone ( ) ,
269
+ escrow_accounts_v1. clone ( ) ,
270
+ escrow_accounts_v2. clone ( ) ,
259
271
timestamp_error_tolerance,
260
272
receipt_max_value,
261
273
)
@@ -299,7 +311,8 @@ impl ServiceRouter {
299
311
deployment_to_allocation,
300
312
} ;
301
313
let sender_state = SenderState {
302
- escrow_accounts,
314
+ escrow_accounts_v1,
315
+ escrow_accounts_v2,
303
316
domain_separator : self . domain_separator ,
304
317
} ;
305
318
0 commit comments