sync: make it more idiomatic rust (#5938)

This commit is contained in:
Guanqun Lu 2017-06-28 00:23:53 +08:00 committed by Arkadiy Paronyan
parent 196c3e7e9b
commit 547031aa0e

View File

@ -92,14 +92,10 @@ impl Snapshot {
/// Find a chunk to download
pub fn needed_chunk(&mut self) -> Option<H256> {
// check state chunks first
let mut chunk = self.pending_state_chunks.iter()
let chunk = self.pending_state_chunks.iter()
.chain(self.pending_block_chunks.iter())
.find(|&h| !self.downloading_chunks.contains(h) && !self.completed_chunks.contains(h))
.cloned();
if chunk.is_none() {
chunk = self.pending_block_chunks.iter()
.find(|&h| !self.downloading_chunks.contains(h) && !self.completed_chunks.contains(h))
.cloned();
}
if let Some(hash) = chunk {
self.downloading_chunks.insert(hash.clone());