Fix panic when downloading stales.

This commit is contained in:
Gav Wood 2016-02-29 14:59:10 +01:00
parent 6197b3ee60
commit 791b0d82aa

View File

@ -245,8 +245,8 @@ impl ChainSync {
start_block_number: self.starting_block,
last_imported_block_number: self.last_imported_block,
highest_block_number: self.highest_block,
blocks_received: match self.last_imported_block { None => 0, Some(x) => x - self.starting_block },
blocks_total: match self.highest_block { None => 0, Some(x) => x - self.starting_block },
blocks_received: match self.last_imported_block { Some(x) if x > self.starting_block => x - self.starting_block, _ => 0 },
blocks_total: match self.highest_block { Some(x) if x > self.starting_block => x - self.starting_block, _ => 0 },
num_peers: self.peers.len(),
num_active_peers: self.peers.values().filter(|p| p.asking != PeerAsking::Nothing).count(),
mem_used: