From 0905372f7027a9d0dbce1a552428b3018c16dde3 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Sat, 6 Feb 2016 22:23:25 +0300 Subject: [PATCH] updating peer best hash when sync --- sync/src/chain.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 5b4e97dc5..89c75feff 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -1113,9 +1113,16 @@ impl ChainSync { }; let mut sent = 0; + let local_best = io.chain().chain_info().best_block_hash; for peer_id in updated_peers { - sent = sent + match ChainSync::create_new_hashes_rlp(io.chain(), &self.peers[&peer_id].latest, &io.chain().chain_info().best_block_hash) { + sent = sent + match ChainSync::create_new_hashes_rlp(io.chain(), + &self.peers.get(&peer_id).expect("ChainSync: unknown peer").latest, + &local_best) { Some(rlp) => { + { + let peer = self.peers.get_mut(&peer_id).expect("ChainSync: unknown peer"); + peer.latest = local_best.clone(); + } self.send_request(io, peer_id, PeerAsking::Nothing, NEW_BLOCK_HASHES_PACKET, rlp); 1 },