From 6d507ef86347762f1221b59f33b49e03c4ec85a3 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 23 Jun 2020 12:08:52 +1000 Subject: [PATCH] Replace unreachable expect with tidier solution (#1278) --- beacon_node/beacon_chain/src/beacon_chain.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 8d3294493..bcd233b53 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -1225,14 +1225,9 @@ impl BeaconChain { } } - while !filtered_chain_segment.is_empty() { + while let Some((_root, block)) = filtered_chain_segment.first() { // Determine the epoch of the first block in the remaining segment. - let start_epoch = filtered_chain_segment - .first() - .map(|(_root, block)| block) - .expect("chain_segment cannot be empty") - .slot() - .epoch(T::EthSpec::slots_per_epoch()); + let start_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch()); // The `last_index` indicates the position of the last block that is in the current // epoch of `start_epoch`.