diff --git a/chain/ethereum/src/ingestor.rs b/chain/ethereum/src/ingestor.rs index 1bedf26876a..d22e08c4294 100644 --- a/chain/ethereum/src/ingestor.rs +++ b/chain/ethereum/src/ingestor.rs @@ -78,7 +78,7 @@ impl PollingBlockIngestor { // To check if there is a new block or not, fetch only the block header since that's cheaper // than the full block. This is worthwhile because most of the time there won't be a new // block, as we expect the poll interval to be much shorter than the block time. - let latest_block = self.latest_block(&logger, ð_adapter).await?; + let latest_block = self.latest_block(logger, ð_adapter).await?; if let Some(head_block) = head_block_ptr_opt.as_ref() { // If latest block matches head block in store, nothing needs to be done diff --git a/chain/ethereum/src/network.rs b/chain/ethereum/src/network.rs index b2860e6b156..9d417e6ccfe 100644 --- a/chain/ethereum/src/network.rs +++ b/chain/ethereum/src/network.rs @@ -80,7 +80,7 @@ pub struct EthereumNetworkAdapters { } impl EthereumNetworkAdapters { - pub fn empty() -> Self { + pub fn empty_for_testing() -> Self { Self { chain_id: "".into(), manager: ProviderManager::default(), @@ -150,6 +150,9 @@ impl EthereumNetworkAdapters { .filter(|adapter| adapter.get_capacity() > AvailableCapacity::Unavailable) } + /// returns all the available adapters that meet the required capabilities + /// if no adapters are available at the time or none that meet the capabilities then + /// an empty iterator is returned. pub async fn all_cheapest_with( &self, required_capabilities: &NodeCapabilities, @@ -164,7 +167,7 @@ impl EthereumNetworkAdapters { } // get all the adapters, don't trigger the ProviderManager's validations because we want - // this function to remain sync + // this function to remain sync. If no adapters are available an empty iterator is returned. pub(crate) fn all_unverified_cheapest_with( &self, required_capabilities: &NodeCapabilities, diff --git a/node/src/chain.rs b/node/src/chain.rs index f2fb8ceabd6..b6247d9a78a 100644 --- a/node/src/chain.rs +++ b/node/src/chain.rs @@ -405,7 +405,7 @@ pub async fn networks_as_chains( let adapters = networks .adapters .iter() - .group_by(|a| a.chain_id()) + .chunk_by(|a| a.chain_id()) .into_iter() .map(|(chain_id, adapters)| (chain_id, adapters.into_iter().collect_vec())) .collect_vec(); @@ -426,7 +426,7 @@ pub async fn networks_as_chains( (k, BlockchainKind::Substreams) => k, (k, _) => k, }) - .expect("each chain should have at least 1 adapter"); + .expect("validation should have checked we have at least one provider"); (chain_id, adapters, kind) }); for (chain_id, adapters, kind) in chains.into_iter() { diff --git a/tests/src/fixture/ethereum.rs b/tests/src/fixture/ethereum.rs index 9bd24dc7097..57a5cc85c95 100644 --- a/tests/src/fixture/ethereum.rs +++ b/tests/src/fixture/ethereum.rs @@ -45,7 +45,7 @@ pub async fn chain( let static_block_stream = Arc::new(StaticStreamBuilder { chain: blocks }); let block_stream_builder = Arc::new(MutexBlockStreamBuilder(Mutex::new(static_block_stream))); - let eth_adapters = Arc::new(EthereumNetworkAdapters::empty()); + let eth_adapters = Arc::new(EthereumNetworkAdapters::empty_for_testing()); let chain = Chain::new( logger_factory,