Parallel block body download (#1659)

This commit is contained in:
Arkadiy Paronyan
2016-07-25 18:38:36 +02:00
committed by Gav Wood
parent 898f1410a5
commit d0e79be5c6
2 changed files with 17 additions and 5 deletions

View File

@@ -120,13 +120,22 @@ impl BlockCollection {
if let Some(head) = head {
match self.blocks.get(&head) {
Some(block) if block.body.is_none() && !self.downloading_bodies.contains(&head) => {
self.downloading_bodies.insert(head.clone());
needed_bodies.push(head.clone());
}
_ => (),
}
}
}
self.downloading_bodies.extend(needed_bodies.iter());
for h in self.header_ids.values() {
if needed_bodies.len() >= count {
break;
}
if !self.downloading_bodies.contains(h) {
needed_bodies.push(h.clone());
self.downloading_bodies.insert(h.clone());
}
}
needed_bodies
}
@@ -286,6 +295,7 @@ impl BlockCollection {
self.parents.insert(info.parent_hash.clone(), hash.clone());
self.blocks.insert(hash.clone(), block);
trace!(target: "sync", "New header: {}", hash.hex());
Ok(hash)
}