Skip to content

Commit 09bd041

Browse files
committed
chain/ethereum: remove rpc client from firehose chain clientff
1 parent 6f92f9e commit 09bd041

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

chain/ethereum/src/chain.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl Chain {
389389
// caller can spawn.
390390
pub async fn cheapest_adapter(&self) -> Arc<EthereumAdapter> {
391391
let adapters = match self.client.as_ref() {
392-
ChainClient::Firehose(_, _) => panic!("no adapter with firehose"),
392+
ChainClient::Firehose(_) => panic!("no adapter with firehose"),
393393
ChainClient::Rpc(adapter) => adapter,
394394
};
395395
adapters.cheapest().await.unwrap()
@@ -472,7 +472,7 @@ impl Blockchain for Chain {
472472
)
473473
.await
474474
}
475-
ChainClient::Firehose(_, _) => {
475+
ChainClient::Firehose(_) => {
476476
self.block_stream_builder
477477
.build_firehose(
478478
self,
@@ -498,7 +498,7 @@ impl Blockchain for Chain {
498498
number: BlockNumber,
499499
) -> Result<BlockPtr, IngestorError> {
500500
match self.client.as_ref() {
501-
ChainClient::Firehose(endpoints, _) => endpoints
501+
ChainClient::Firehose(endpoints) => endpoints
502502
.endpoint()
503503
.await?
504504
.block_ptr_for_number::<HeaderOnlyBlock>(logger, number)
@@ -557,7 +557,7 @@ impl Blockchain for Chain {
557557

558558
async fn block_ingestor(&self) -> anyhow::Result<Box<dyn BlockIngestor>> {
559559
let ingestor: Box<dyn BlockIngestor> = match self.chain_client().as_ref() {
560-
ChainClient::Firehose(_, _) => {
560+
ChainClient::Firehose(_) => {
561561
let ingestor = FirehoseBlockIngestor::<HeaderOnlyBlock, Self>::new(
562562
self.chain_store.cheap_clone(),
563563
self.chain_client(),
@@ -852,7 +852,7 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
852852
use graph::prelude::LightEthereumBlockExt;
853853

854854
let block = match self.chain_client.as_ref() {
855-
ChainClient::Firehose(_, _) => Some(BlockPtr {
855+
ChainClient::Firehose(_) => Some(BlockPtr {
856856
hash: BlockHash::from(vec![0xff; 32]),
857857
number: block.number.saturating_sub(1),
858858
}),

graph/src/blockchain/client.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@ use anyhow::anyhow;
1111
// Substreams only requires the FirehoseEndpoints.
1212
#[derive(Debug)]
1313
pub enum ChainClient<C: Blockchain> {
14-
Firehose(FirehoseEndpoints, Option<C::Client>),
14+
Firehose(FirehoseEndpoints),
1515
Rpc(C::Client),
1616
}
1717

1818
impl<C: Blockchain> ChainClient<C> {
1919
pub fn new_firehose(firehose_endpoints: FirehoseEndpoints) -> Self {
20-
Self::Firehose(firehose_endpoints, None)
21-
}
22-
23-
pub fn new_firehose_with_rpc(firehose_endpoints: FirehoseEndpoints, rpc: C::Client) -> Self {
24-
Self::Firehose(firehose_endpoints, Some(rpc))
20+
Self::Firehose(firehose_endpoints)
2521
}
2622

2723
pub fn new_rpc(rpc: C::Client) -> Self {
@@ -30,23 +26,22 @@ impl<C: Blockchain> ChainClient<C> {
3026

3127
pub fn is_firehose(&self) -> bool {
3228
match self {
33-
ChainClient::Firehose(_, _) => true,
29+
ChainClient::Firehose(_) => true,
3430
ChainClient::Rpc(_) => false,
3531
}
3632
}
3733

3834
pub async fn firehose_endpoint(&self) -> anyhow::Result<Arc<FirehoseEndpoint>> {
3935
match self {
40-
ChainClient::Firehose(endpoints, _) => endpoints.endpoint().await,
36+
ChainClient::Firehose(endpoints) => endpoints.endpoint().await,
4137
_ => Err(anyhow!("firehose endpoint requested on rpc chain client")),
4238
}
4339
}
4440

4541
pub fn rpc(&self) -> anyhow::Result<&C::Client> {
4642
match self {
4743
Self::Rpc(rpc) => Ok(rpc),
48-
Self::Firehose(_, Some(rpc)) => Ok(rpc),
49-
_ => Err(anyhow!("rpc endpoint requested on firehose chain client")),
44+
Self::Firehose(_) => Err(anyhow!("rpc endpoint requested on firehose chain client")),
5045
}
5146
}
5247
}

node/src/chain.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,7 @@ pub async fn networks_as_chains(
523523
let eth_adapters = networks.ethereum_rpcs(chain_id.clone());
524524

525525
let cc = if firehose_endpoints.len() > 0 {
526-
ChainClient::<graph_chain_ethereum::Chain>::new_firehose_with_rpc(
527-
firehose_endpoints,
528-
eth_adapters.clone(),
529-
)
526+
ChainClient::<graph_chain_ethereum::Chain>::new_firehose(firehose_endpoints)
530527
} else {
531528
ChainClient::<graph_chain_ethereum::Chain>::new_rpc(eth_adapters.clone())
532529
};

0 commit comments

Comments
 (0)