From ce91dc51f7f38fd342ab97fd3eea14f07f3ee77d Mon Sep 17 00:00:00 2001 From: Javier Viola Date: Wed, 27 Sep 2023 15:09:25 -0300 Subject: [PATCH] Update crates/orchestrator/src/network_spec/relaychain.rs Co-authored-by: Loris Moulin <45130584+l0r1s@users.noreply.github.com> --- .../src/network_spec/relaychain.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/orchestrator/src/network_spec/relaychain.rs b/crates/orchestrator/src/network_spec/relaychain.rs index 036d10264..14b77528b 100644 --- a/crates/orchestrator/src/network_spec/relaychain.rs +++ b/crates/orchestrator/src/network_spec/relaychain.rs @@ -89,13 +89,17 @@ impl RelaychainSpec { // We want to track the errors for all the nodes and report them ones let mut errs: Vec = Default::default(); - let mut nodes: Vec = Default::default(); - config.nodes().iter().for_each(|node_config| { - match NodeSpec::from_config(node_config, &chain_context) { - Ok(node) => nodes.push(node), - Err(err) => errs.push(err), - } - }); + let (nodes, errs) = config + .nodes() + .iter() + .map(|node_config| NodeSpec::from_config(node_config, &chain_context)) + .fold((vec![], vec![]), |(mut nodes, mut errs), result| { + match result { + Ok(node) => nodes.push(node), + Err(err) => errs.push(err), + } + (nodes, errs) + }); if !errs.is_empty() { // TODO: merge errs