@@ -133,82 +133,40 @@ impl BlockStreamBuilder<Chain> for EthereumStreamBuilder {
133133 filter : Arc < TriggerFilterWrapper < Chain > > ,
134134 unified_api_version : UnifiedMappingApiVersion ,
135135 ) -> Result < Box < dyn BlockStream < Chain > > > {
136- let requirements = filter. filter . node_capabilities ( ) ;
137- let adapter = chain
138- . triggers_adapter ( & deployment, & requirements, unified_api_version. clone ( ) )
139- . unwrap_or_else ( |_| {
140- panic ! (
141- "no adapter for network {} with capabilities {}" ,
142- chain. name, requirements
143- )
144- } ) ;
145-
146- let adapter = Arc :: new ( TriggersAdapterWrapper :: new ( adapter, source_subgraph_stores) ) ;
147-
148- let logger = chain
149- . logger_factory
150- . subgraph_logger ( & deployment)
151- . new ( o ! ( "component" => "BlockStream" ) ) ;
152- let chain_store = chain. chain_store ( ) ;
153- let chain_head_update_stream = chain
154- . chain_head_update_listener
155- . subscribe ( chain. name . to_string ( ) , logger. clone ( ) ) ;
156-
157- // Special case: Detect Celo and set the threshold to 0, so that eth_getLogs is always used.
158- // This is ok because Celo blocks are always final. And we _need_ to do this because
159- // some events appear only in eth_getLogs but not in transaction receipts.
160- // See also ca0edc58-0ec5-4c89-a7dd-2241797f5e50.
161- let chain_id = match chain. chain_client ( ) . as_ref ( ) {
162- ChainClient :: Rpc ( adapter) => {
163- adapter
164- . cheapest ( )
165- . await
166- . ok_or ( anyhow ! ( "unable to get eth adapter for chan_id call" ) ) ?
167- . chain_id ( )
168- . await ?
169- }
170- _ => panic ! ( "expected rpc when using polling blockstream" ) ,
171- } ;
172- let reorg_threshold = match CELO_CHAIN_IDS . contains ( & chain_id) {
173- false => chain. reorg_threshold ,
174- true => 0 ,
175- } ;
176-
177- Ok ( Box :: new ( PollingBlockStream :: new (
178- chain_store,
179- chain_head_update_stream,
180- adapter,
181- chain. node_id . clone ( ) ,
182- deployment. hash ,
183- filter,
136+ self . build_polling (
137+ chain,
138+ deployment,
184139 start_blocks,
185- reorg_threshold,
186- logger,
187- ENV_VARS . max_block_range_size ,
188- ENV_VARS . target_triggers_per_block_range ,
189- unified_api_version,
140+ source_subgraph_stores,
190141 subgraph_current_block,
191- ) ) )
142+ filter,
143+ unified_api_version,
144+ )
145+ . await
192146 }
193147
194148 async fn build_polling (
195149 & self ,
196150 chain : & Chain ,
197151 deployment : DeploymentLocator ,
198152 start_blocks : Vec < BlockNumber > ,
153+ source_subgraph_stores : Vec < ( DeploymentHash , Arc < dyn WritableStore > ) > ,
199154 subgraph_current_block : Option < BlockPtr > ,
200155 filter : Arc < TriggerFilterWrapper < Chain > > ,
201156 unified_api_version : UnifiedMappingApiVersion ,
202157 ) -> Result < Box < dyn BlockStream < Chain > > > {
203158 let requirements = filter. filter . node_capabilities ( ) ;
204- let adapter = chain
205- . triggers_adapter ( & deployment, & requirements, unified_api_version. clone ( ) )
206- . unwrap_or_else ( |_| {
207- panic ! (
208- "no adapter for network {} with capabilities {}" ,
209- chain. name, requirements
210- )
211- } ) ;
159+ let adapter = TriggersAdapterWrapper :: new (
160+ chain
161+ . triggers_adapter ( & deployment, & requirements, unified_api_version. clone ( ) )
162+ . unwrap_or_else ( |_| {
163+ panic ! (
164+ "no adapter for network {} with capabilities {}" ,
165+ chain. name, requirements
166+ )
167+ } ) ,
168+ source_subgraph_stores,
169+ ) ;
212170
213171 let logger = chain
214172 . logger_factory
@@ -242,7 +200,7 @@ impl BlockStreamBuilder<Chain> for EthereumStreamBuilder {
242200 Ok ( Box :: new ( PollingBlockStream :: new (
243201 chain_store,
244202 chain_head_update_stream,
245- adapter,
203+ Arc :: new ( adapter) ,
246204 chain. node_id . clone ( ) ,
247205 deployment. hash ,
248206 filter,
@@ -507,6 +465,7 @@ impl Blockchain for Chain {
507465 self ,
508466 deployment,
509467 start_blocks,
468+ source_subgraph_stores,
510469 current_ptr,
511470 filter,
512471 unified_api_version,
0 commit comments