Skip to content

Commit 74cddcb

Browse files
committed
fix(rustfmt): fix rustfmt errors in chain/ethereum/src/network.rs
1 parent b81fe2d commit 74cddcb

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

chain/ethereum/src/network.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl EthereumNetworkAdapters {
197197
Self::available_with_capabilities(all, required_capabilities)
198198
}
199199

200-
""" // handle adapter selection from a list, implements the availability checking with an abstracted
200+
// handle adapter selection from a list, implements the availability checking with an abstracted
201201
// source of the adapter list.
202202
fn cheapest_from(
203203
&self,
@@ -213,8 +213,11 @@ impl EthereumNetworkAdapters {
213213
self.select_best_adapter(input, required_capabilities)
214214
}
215215

216-
fn retest_errored_adapter(&self, input: &[&EthereumNetworkAdapter]) -> Option<Arc<EthereumAdapter>> {
217-
let retest_rng: f64 = (&mut rand::rng()).random();
216+
fn retest_errored_adapter(
217+
&self,
218+
input: &[&EthereumNetworkAdapter],
219+
) -> Option<Arc<EthereumAdapter>> {
220+
let retest_rng: f64 = rand::thread_rng().gen();
218221
if retest_rng < self.retest_percent {
219222
input
220223
.iter()
@@ -250,7 +253,7 @@ impl EthereumNetworkAdapters {
250253
}
251254
let weights: Vec<_> = input.iter().map(|a| a.weight).collect();
252255
if let Ok(dist) = WeightedIndex::new(&weights) {
253-
let idx = dist.sample(&mut rand::rng());
256+
let idx = dist.sample(&mut rand::thread_rng());
254257
Ok(input[idx].adapter.clone())
255258
} else {
256259
// Fallback to random selection if weights are invalid
@@ -263,7 +266,9 @@ impl EthereumNetworkAdapters {
263266
input: Vec<&EthereumNetworkAdapter>,
264267
required_capabilities: &NodeCapabilities,
265268
) -> Result<Arc<EthereumAdapter>, Error> {
266-
let choices = input.into_iter().choose_multiple(&mut rand::rng(), 3);
269+
let choices = input
270+
.into_iter()
271+
.choose_multiple(&mut rand::thread_rng(), 3);
267272
if let Some(adapter) = choices.iter().min_by_key(|a| a.current_error_count()) {
268273
Ok(adapter.adapter.clone())
269274
} else {
@@ -272,7 +277,7 @@ impl EthereumNetworkAdapters {
272277
required_capabilities
273278
))
274279
}
275-
}""
280+
}
276281

277282
pub(crate) fn unverified_cheapest_with(
278283
&self,
@@ -339,15 +344,15 @@ impl EthereumNetworkAdapters {
339344
.call_only_adapters
340345
.iter()
341346
.min_by_key(|x| Arc::strong_count(&x.adapter))
342-
.ok_or(anyhow!("no available call only endpoints"))?;
347+
.ok_or(anyhow!("no available call only endpoints "))?;
343348

344349
// TODO: This will probably blow up a lot sooner than [limit] amount of
345350
// subgraphs, since we probably use a few instances.
346351
if !adapters
347352
.limit
348353
.has_capacity(Arc::strong_count(&adapters.adapter))
349354
{
350-
bail!("call only adapter has reached the concurrency limit");
355+
bail!("call only adapter has reached the concurrency limit ");
351356
}
352357

353358
// Cloning here ensure we have the correct count at any given time, if we return a reference it can be cloned later
@@ -364,11 +369,11 @@ mod tests {
364369
use graph::components::network_provider::ProviderName;
365370
use graph::data::value::Word;
366371
use graph::http::HeaderMap;
372+
use graph::slog::{o, Discard, Logger};
367373
use graph::{
368374
endpoint::EndpointMetrics,
369375
firehose::SubgraphLimit,
370-
prelude::MetricsRegistry,
371-
slog::{o, Discard, Logger},
376+
prelude::{MetricsRegistry, SubgraphAssignmentProvider},
372377
tokio,
373378
url::Url,
374379
};
@@ -788,6 +793,7 @@ mod tests {
788793
},
789794
adapter: adapter.clone(),
790795
limit: limit.clone(),
796+
weight: 1.0,
791797
});
792798
always_retest_adapters.push(EthereumNetworkAdapter {
793799
endpoint_metrics: metrics.clone(),
@@ -797,6 +803,7 @@ mod tests {
797803
},
798804
adapter,
799805
limit,
806+
weight: 1.0,
800807
});
801808
});
802809
let manager = ProviderManager::<EthereumNetworkAdapter>::new(
@@ -878,6 +885,7 @@ mod tests {
878885
adapter: fake_adapter(&logger, &error_provider, &provider_metrics, &metrics, false)
879886
.await,
880887
limit: SubgraphLimit::Unlimited,
888+
weight: 1.0,
881889
});
882890

883891
let mut always_retest_adapters = vec![];
@@ -896,6 +904,7 @@ mod tests {
896904
)
897905
.await,
898906
limit: SubgraphLimit::Unlimited,
907+
weight: 1.0,
899908
});
900909
let manager = ProviderManager::<EthereumNetworkAdapter>::new(
901910
logger.clone(),
@@ -965,6 +974,7 @@ mod tests {
965974
)
966975
.await,
967976
limit: SubgraphLimit::Disabled,
977+
weight: 1.0,
968978
});
969979
let manager = ProviderManager::new(
970980
logger,

0 commit comments

Comments
 (0)