Check before borrow, fixes #267

This commit is contained in:
Ignotus Peverell 2017-12-03 12:46:00 +00:00 committed by Simon B
parent 1a86900bac
commit cac6181c21

View file

@ -249,7 +249,7 @@ impl NetAdapter for NetToChainAdapter {
self.total_height() self.total_height()
); );
if self.p2p_server.is_initialized() { if diff.into_num() > 0 && self.p2p_server.is_initialized() {
if let Some(peer) = self.p2p_server.borrow().get_peer(&addr) { if let Some(peer) = self.p2p_server.borrow().get_peer(&addr) {
let mut peer = peer.write().unwrap(); let mut peer = peer.write().unwrap();
peer.info.total_difficulty = diff; peer.info.total_difficulty = diff;
@ -321,7 +321,7 @@ impl NetToChainAdapter {
} }
self.syncing.load(Ordering::Relaxed) self.syncing.load(Ordering::Relaxed)
} }
// recursively go back through the locator vector and stop when we find // recursively go back through the locator vector and stop when we find
// a header that we recognize this will be a header shared in common // a header that we recognize this will be a header shared in common
// between us and the peer // between us and the peer