1
- use std:: collections:: HashSet ;
2
- use std:: iter:: FromIterator ;
3
- use std:: sync:: Arc ;
4
-
5
1
use anyhow:: { Context , Error } ;
6
2
use graph:: data:: subgraph:: UnifiedMappingApiVersion ;
7
- use graph:: prelude:: { EthereumCallCache , LightEthereumBlock , LightEthereumBlockExt } ;
3
+ use graph:: prelude:: {
4
+ EthereumCallCache , LightEthereumBlock , LightEthereumBlockExt , StopwatchMetrics ,
5
+ } ;
8
6
use graph:: {
9
7
blockchain:: {
10
8
block_stream:: {
@@ -23,6 +21,9 @@ use graph::{
23
21
SubgraphStore ,
24
22
} ,
25
23
} ;
24
+ use std:: collections:: HashSet ;
25
+ use std:: iter:: FromIterator ;
26
+ use std:: sync:: Arc ;
26
27
27
28
use crate :: data_source:: DataSourceTemplate ;
28
29
use crate :: data_source:: UnresolvedDataSourceTemplate ;
@@ -140,6 +141,7 @@ impl Blockchain for Chain {
140
141
loc : & DeploymentLocator ,
141
142
capabilities : & Self :: NodeCapabilities ,
142
143
unified_api_version : UnifiedMappingApiVersion ,
144
+ stopwatch_metrics : StopwatchMetrics ,
143
145
) -> Result < Arc < Self :: TriggersAdapter > , Error > {
144
146
let eth_adapter = self . eth_adapters . cheapest_with ( capabilities) ?. clone ( ) ;
145
147
let logger = self
@@ -152,8 +154,9 @@ impl Blockchain for Chain {
152
154
logger,
153
155
ethrpc_metrics,
154
156
eth_adapter,
157
+ stopwatch_metrics,
155
158
chain_store : self . chain_store . cheap_clone ( ) ,
156
- _unified_api_version : unified_api_version,
159
+ unified_api_version,
157
160
} ;
158
161
Ok ( Arc :: new ( adapter) )
159
162
}
@@ -180,7 +183,12 @@ impl Blockchain for Chain {
180
183
let requirements = filter. node_capabilities ( ) ;
181
184
182
185
let triggers_adapter = self
183
- . triggers_adapter ( & deployment, & requirements, unified_api_version. clone ( ) )
186
+ . triggers_adapter (
187
+ & deployment,
188
+ & requirements,
189
+ unified_api_version. clone ( ) ,
190
+ metrics. stopwatch . clone ( ) ,
191
+ )
184
192
. expect ( & format ! (
185
193
"no adapter for network {} with capabilities {}" ,
186
194
self . name, requirements
@@ -306,9 +314,10 @@ pub struct DummyDataSourceTemplate;
306
314
pub struct TriggersAdapter {
307
315
logger : Logger ,
308
316
ethrpc_metrics : Arc < SubgraphEthRpcMetrics > ,
317
+ stopwatch_metrics : StopwatchMetrics ,
309
318
chain_store : Arc < dyn ChainStore > ,
310
319
eth_adapter : Arc < EthereumAdapter > ,
311
- _unified_api_version : UnifiedMappingApiVersion ,
320
+ unified_api_version : UnifiedMappingApiVersion ,
312
321
}
313
322
314
323
#[ async_trait]
@@ -324,9 +333,11 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
324
333
self . logger . clone ( ) ,
325
334
self . chain_store . clone ( ) ,
326
335
self . ethrpc_metrics . clone ( ) ,
336
+ self . stopwatch_metrics . clone ( ) ,
327
337
from,
328
338
to,
329
339
filter,
340
+ self . unified_api_version . clone ( ) ,
330
341
)
331
342
. await
332
343
}
@@ -354,9 +365,11 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
354
365
logger. clone ( ) ,
355
366
self . chain_store . clone ( ) ,
356
367
self . ethrpc_metrics . clone ( ) ,
368
+ self . stopwatch_metrics . clone ( ) ,
357
369
block_number,
358
370
block_number,
359
371
filter,
372
+ self . unified_api_version . clone ( ) ,
360
373
)
361
374
. await ?;
362
375
assert ! ( blocks. len( ) == 1 ) ;
@@ -368,7 +381,7 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
368
381
& filter. log ,
369
382
& full_block. ethereum_block ,
370
383
) ) ;
371
- triggers. append ( & mut parse_call_triggers ( & filter. call , & full_block) ) ;
384
+ triggers. append ( & mut parse_call_triggers ( & filter. call , & full_block) ? ) ;
372
385
triggers. append ( & mut parse_block_triggers ( filter. block . clone ( ) , & full_block) ) ;
373
386
Ok ( BlockWithTriggers :: new ( block, triggers) )
374
387
}
0 commit comments