address grumbles

This commit is contained in:
Robert Habermeier 2016-12-27 12:24:18 +01:00
parent 0688ccb003
commit 55dbfbf35b

View File

@ -117,21 +117,16 @@ impl HeaderChain {
let mut candidates = self.candidates.write(); let mut candidates = self.candidates.write();
// find parent details. // find parent details.
let parent_td = { let parent_td =
if number == 1 { if number == 1 {
let g_view = HeaderView::new(&self.genesis_header); let g_view = HeaderView::new(&self.genesis_header);
g_view.difficulty() g_view.difficulty()
} else { } else {
let maybe_td = candidates.get(&(number - 1)) candidates.get(&(number - 1))
.and_then(|entry| entry.candidates.iter().find(|c| c.hash == parent_hash)) .and_then(|entry| entry.candidates.iter().find(|c| c.hash == parent_hash))
.map(|c| c.total_difficulty); .map(|c| c.total_difficulty)
.ok_or_else(|| BlockError::UnknownParent(parent_hash))?
match maybe_td { };
Some(td) => td,
None => return Err(BlockError::UnknownParent(parent_hash)),
}
}
};
let total_difficulty = parent_td + view.difficulty(); let total_difficulty = parent_td + view.difficulty();
@ -230,9 +225,7 @@ impl HeaderChain {
/// Get the genesis hash. /// Get the genesis hash.
pub fn genesis_hash(&self) -> H256 { pub fn genesis_hash(&self) -> H256 {
use util::Hashable; ::util::Hashable::sha3(&self.genesis_header)
self.genesis_header.sha3()
} }
/// Get the best block's data. /// Get the best block's data.