From 55dbfbf35bfaab78e761f6021ee6203ce7448214 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Tue, 27 Dec 2016 12:24:18 +0100 Subject: [PATCH] address grumbles --- ethcore/light/src/client/header_chain.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index 388f54d5a..fdb075e04 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -117,21 +117,16 @@ impl HeaderChain { let mut candidates = self.candidates.write(); // find parent details. - let parent_td = { + let parent_td = if number == 1 { let g_view = HeaderView::new(&self.genesis_header); g_view.difficulty() } else { - let maybe_td = candidates.get(&(number - 1)) + candidates.get(&(number - 1)) .and_then(|entry| entry.candidates.iter().find(|c| c.hash == parent_hash)) - .map(|c| c.total_difficulty); - - match maybe_td { - Some(td) => td, - None => return Err(BlockError::UnknownParent(parent_hash)), - } - } - }; + .map(|c| c.total_difficulty) + .ok_or_else(|| BlockError::UnknownParent(parent_hash))? + }; let total_difficulty = parent_td + view.difficulty(); @@ -230,9 +225,7 @@ impl HeaderChain { /// Get the genesis hash. pub fn genesis_hash(&self) -> H256 { - use util::Hashable; - - self.genesis_header.sha3() + ::util::Hashable::sha3(&self.genesis_header) } /// Get the best block's data.