Skip to content

Commit 05e838a

Browse files
authored
Enable support for substreams on already supported networks (#4767)
1 parent 399b732 commit 05e838a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

node/src/main.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ async fn main() {
367367
&mut blockchain_map,
368368
&logger,
369369
&arweave_networks,
370+
substreams_networks_by_kind.get(&BlockchainKind::Arweave),
370371
network_store.as_ref(),
371372
&logger_factory,
372373
metrics_registry.clone(),
@@ -396,6 +397,7 @@ async fn main() {
396397
&mut blockchain_map,
397398
&logger,
398399
&near_networks,
400+
substreams_networks_by_kind.get(&BlockchainKind::Near),
399401
network_store.as_ref(),
400402
&logger_factory,
401403
metrics_registry.clone(),
@@ -405,6 +407,7 @@ async fn main() {
405407
&mut blockchain_map,
406408
&logger,
407409
&cosmos_networks,
410+
substreams_networks_by_kind.get(&BlockchainKind::Cosmos),
408411
network_store.as_ref(),
409412
&logger_factory,
410413
metrics_registry.clone(),
@@ -651,6 +654,7 @@ fn networks_as_chains<C>(
651654
blockchain_map: &mut BlockchainMap,
652655
logger: &Logger,
653656
firehose_networks: &FirehoseNetworks,
657+
substreams_networks: Option<&FirehoseNetworks>,
654658
store: &Store,
655659
logger_factory: &LoggerFactory,
656660
metrics_registry: Arc<MetricsRegistry>,
@@ -698,6 +702,26 @@ where
698702
blockchain_map.insert::<C>(chain_id.clone(), chain.clone())
699703
}
700704

705+
if let Some(substreams_networks) = substreams_networks {
706+
for (network_name, firehose_endpoints) in substreams_networks.networks.iter() {
707+
let chain_store = blockchain_map
708+
.get::<C>(network_name.clone())
709+
.expect("any substreams endpoint needs an rpc or firehose chain defined")
710+
.chain_store();
711+
712+
blockchain_map.insert::<substreams::Chain>(
713+
network_name.clone(),
714+
Arc::new(substreams::Chain::new(
715+
logger_factory.clone(),
716+
firehose_endpoints.clone(),
717+
metrics_registry.clone(),
718+
chain_store,
719+
Arc::new(substreams::BlockStreamBuilder::new()),
720+
)),
721+
);
722+
}
723+
}
724+
701725
HashMap::from_iter(chains)
702726
}
703727

0 commit comments

Comments
 (0)