Skip to content

Commit

Permalink
code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mangas committed Jun 12, 2024
1 parent daf4d11 commit 06523cf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion chain/ethereum/src/ingestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, &eth_adapter).await?;
let latest_block = self.latest_block(logger, &eth_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
Expand Down
7 changes: 5 additions & 2 deletions chain/ethereum/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion node/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/fixture/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 06523cf

Please sign in to comment.