Skip to content

Commit 80044d3

Browse files
committed
fix(aggregator-discoverer): 'CapableAggregatorDiscovererIterator' implementation of 'Iterator' trait
1 parent 24cc8ef commit 80044d3

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

internal/mithril-aggregator-discovery/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ serde_json = { workspace = true }
3434
slog = { workspace = true }
3535
slog-scope = "4.4.0"
3636
thiserror = { workspace = true }
37-
tokio = { workspace = true, features = ["sync"] }
37+
tokio = { workspace = true, features = ["sync", "rt-multi-thread"] }
3838

3939
[dev-dependencies]
4040
mockall = { workspace = true }

internal/mithril-aggregator-discovery/src/capabilities_discoverer.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,20 @@ impl Iterator for CapableAggregatorDiscovererIterator {
5454
type Item = AggregatorEndpoint;
5555

5656
fn next(&mut self) -> Option<Self::Item> {
57-
for aggregator_endpoint in &mut self.inner_iterator {
58-
let aggregator_capabilities = tokio::runtime::Handle::current()
59-
.block_on(async { aggregator_endpoint.retrieve_capabilities().await });
60-
if CapableAggregatorDiscoverer::capabilities_match(
61-
&self.capabilities,
62-
&aggregator_capabilities.ok()?,
63-
) {
64-
return Some(aggregator_endpoint);
57+
while let Some(aggregator_endpoint) = self.inner_iterator.next() {
58+
let aggregator_endpoint_clone = aggregator_endpoint.clone();
59+
let aggregator_capabilities = tokio::task::block_in_place(move || {
60+
tokio::runtime::Handle::current().block_on(async move {
61+
aggregator_endpoint_clone.retrieve_capabilities().await
62+
})
63+
});
64+
if let Ok(aggregator_capabilities) = aggregator_capabilities {
65+
if CapableAggregatorDiscoverer::capabilities_match(
66+
&self.capabilities,
67+
&aggregator_capabilities,
68+
) {
69+
return Some(aggregator_endpoint);
70+
}
6571
}
6672
}
6773

0 commit comments

Comments
 (0)