Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
mangas committed May 14, 2024
1 parent a2c7264 commit cdfca0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 137 deletions.
90 changes: 0 additions & 90 deletions chain/ethereum/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,96 +298,6 @@ impl EthereumNetworkAdapters {
}
}

// #[derive(Debug, Clone)]
// pub struct EthereumNetworks {
// pub logger: Logger,
// pub metrics: Arc<EndpointMetrics>,
// pub networks: HashMap<String, EthereumNetworkAdapters>,
// }

// impl EthereumNetworks {
// pub fn new(logger: Logger, metrics: Arc<EndpointMetrics>) -> EthereumNetworks {
// EthereumNetworks {
// networks: HashMap::new(),
// metrics,
// logger,
// }
// }

// pub fn insert_empty(&mut self, name: String) {
// self.networks.entry(name).or_default();
// }

// pub fn insert(
// &mut self,
// name: String,
// capabilities: NodeCapabilities,
// adapter: Arc<EthereumAdapter>,
// limit: SubgraphLimit,
// ) {
// let network_adapters = self.networks.entry(name).or_default();

// network_adapters.push_adapter(EthereumNetworkAdapter {
// capabilities,
// adapter,
// limit,
// endpoint_metrics: self.metrics.cheap_clone(),
// });
// }

// pub fn remove(&mut self, name: &str, provider: &str) {
// if let Some(adapters) = self.networks.get_mut(name) {
// adapters.remove(provider);
// }
// }

// pub fn extend(&mut self, other_networks: EthereumNetworks) {
// self.networks.extend(other_networks.networks);
// }

// pub fn flatten(&self) -> Vec<(String, NodeCapabilities, Arc<EthereumAdapter>)> {
// self.networks
// .iter()
// .flat_map(|(network_name, network_adapters)| {
// network_adapters
// .adapters
// .iter()
// .map(move |network_adapter| {
// (
// network_name.clone(),
// network_adapter.capabilities,
// network_adapter.adapter.clone(),
// )
// })
// })
// .collect()
// }

// pub fn sort(&mut self) {
// for adapters in self.networks.values_mut() {
// adapters.adapters.sort_by(|a, b| {
// a.capabilities
// .partial_cmp(&b.capabilities)
// // We can't define a total ordering over node capabilities,
// // so incomparable items are considered equal and end up
// // near each other.
// .unwrap_or(Ordering::Equal)
// })
// }
// }

// pub fn adapter_with_capabilities(
// &self,
// network_name: String,
// requirements: &NodeCapabilities,
// ) -> Result<Arc<EthereumAdapter>, Error> {
// self.networks
// .get(&network_name)
// .ok_or(anyhow!("network not supported: {}", &network_name))
// .and_then(|adapters| adapters.cheapest_with(requirements))
// }
// }

#[cfg(test)]
mod tests {
use graph::cheap_clone::CheapClone;
Expand Down
49 changes: 2 additions & 47 deletions graph/src/firehose/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@ use itertools::Itertools;
use prost::Message;
use slog::Logger;
use std::{
collections::{BTreeMap, HashMap},
fmt::Display,
marker::PhantomData,
ops::ControlFlow,
str::FromStr,
sync::Arc,
time::Duration,
collections::HashMap, fmt::Display, marker::PhantomData, ops::ControlFlow, str::FromStr,
sync::Arc, time::Duration,
};
use tonic::codegen::InterceptedService;
use tonic::{
Expand Down Expand Up @@ -692,46 +687,6 @@ impl FirehoseEndpoints {
}
}

#[derive(Clone, Debug)]
pub struct FirehoseNetworks {
/// networks contains a map from chain id (`near-mainnet`, `near-testnet`, `solana-mainnet`, etc.)
/// to a list of FirehoseEndpoint (type wrapper around `Arc<Vec<FirehoseEndpoint>>`).
pub networks: BTreeMap<String, Vec<Arc<FirehoseEndpoint>>>,
}

impl FirehoseNetworks {
pub fn new() -> FirehoseNetworks {
FirehoseNetworks {
networks: BTreeMap::new(),
}
}

pub fn insert(&mut self, chain_id: String, endpoint: Arc<FirehoseEndpoint>) {
let endpoints = self.networks.entry(chain_id).or_insert_with(|| Vec::new());

endpoints.push(endpoint);
}

/// Returns a `HashMap` where the key is the chain's id and the key is an endpoint for this chain.
/// There can be multiple keys with the same chain id but with different
/// endpoint where multiple providers exist for a single chain id. Providers with the same
/// label do not need to be tested individually, if one is working, every other endpoint in the
/// pool should also work.
pub fn flatten(&self) -> HashMap<(String, Word), Arc<FirehoseEndpoint>> {
self.networks
.iter()
.flat_map(|(chain_id, firehose_endpoints)| {
firehose_endpoints.iter().map(move |endpoint| {
(
(chain_id.clone(), endpoint.provider.clone()),
endpoint.clone(),
)
})
})
.collect()
}
}

#[cfg(test)]
mod test {
use std::{mem, sync::Arc};
Expand Down

0 comments on commit cdfca0f

Please sign in to comment.