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
LoggerFactory , MetricsRegistry , NodeId , 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 ;
@@ -142,6 +143,7 @@ impl Blockchain for Chain {
142
143
loc : & DeploymentLocator ,
143
144
capabilities : & Self :: NodeCapabilities ,
144
145
unified_api_version : UnifiedMappingApiVersion ,
146
+ stopwatch_metrics : StopwatchMetrics ,
145
147
) -> Result < Arc < Self :: TriggersAdapter > , Error > {
146
148
let eth_adapter = self . eth_adapters . cheapest_with ( capabilities) ?. clone ( ) ;
147
149
let logger = self
@@ -154,8 +156,9 @@ impl Blockchain for Chain {
154
156
logger,
155
157
ethrpc_metrics,
156
158
eth_adapter,
159
+ stopwatch_metrics,
157
160
chain_store : self . chain_store . cheap_clone ( ) ,
158
- _unified_api_version : unified_api_version,
161
+ unified_api_version,
159
162
} ;
160
163
Ok ( Arc :: new ( adapter) )
161
164
}
@@ -182,7 +185,12 @@ impl Blockchain for Chain {
182
185
let requirements = filter. node_capabilities ( ) ;
183
186
184
187
let triggers_adapter = self
185
- . triggers_adapter ( & deployment, & requirements, unified_api_version. clone ( ) )
188
+ . triggers_adapter (
189
+ & deployment,
190
+ & requirements,
191
+ unified_api_version. clone ( ) ,
192
+ metrics. stopwatch . clone ( ) ,
193
+ )
186
194
. expect ( & format ! (
187
195
"no adapter for network {} with capabilities {}" ,
188
196
self . name, requirements
@@ -330,9 +338,10 @@ impl Manifest<Chain> for DummyManifest {
330
338
pub struct TriggersAdapter {
331
339
logger : Logger ,
332
340
ethrpc_metrics : Arc < SubgraphEthRpcMetrics > ,
341
+ stopwatch_metrics : StopwatchMetrics ,
333
342
chain_store : Arc < dyn ChainStore > ,
334
343
eth_adapter : Arc < EthereumAdapter > ,
335
- _unified_api_version : UnifiedMappingApiVersion ,
344
+ unified_api_version : UnifiedMappingApiVersion ,
336
345
}
337
346
338
347
#[ async_trait]
@@ -348,9 +357,11 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
348
357
self . logger . clone ( ) ,
349
358
self . chain_store . clone ( ) ,
350
359
self . ethrpc_metrics . clone ( ) ,
360
+ self . stopwatch_metrics . clone ( ) ,
351
361
from,
352
362
to,
353
363
filter,
364
+ self . unified_api_version . clone ( ) ,
354
365
)
355
366
. await
356
367
}
@@ -378,9 +389,11 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
378
389
logger. clone ( ) ,
379
390
self . chain_store . clone ( ) ,
380
391
self . ethrpc_metrics . clone ( ) ,
392
+ self . stopwatch_metrics . clone ( ) ,
381
393
block_number,
382
394
block_number,
383
395
filter,
396
+ self . unified_api_version . clone ( ) ,
384
397
)
385
398
. await ?;
386
399
assert ! ( blocks. len( ) == 1 ) ;
@@ -392,7 +405,7 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
392
405
& filter. log ,
393
406
& full_block. ethereum_block ,
394
407
) ) ;
395
- triggers. append ( & mut parse_call_triggers ( & filter. call , & full_block) ) ;
408
+ triggers. append ( & mut parse_call_triggers ( & filter. call , & full_block) ? ) ;
396
409
triggers. append ( & mut parse_block_triggers ( filter. block . clone ( ) , & full_block) ) ;
397
410
Ok ( BlockWithTriggers :: new ( block, triggers) )
398
411
}
0 commit comments