From 53b221e4c4776dcfc5d64b0e277912900fbce584 Mon Sep 17 00:00:00 2001 From: Yahtoo Ma Date: Thu, 12 Apr 2018 17:37:22 +0800 Subject: [PATCH] Add block sync sw peer check --- netsync/sync.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netsync/sync.go b/netsync/sync.go index 5afc4bc7..1411a05c 100644 --- a/netsync/sync.go +++ b/netsync/sync.go @@ -88,6 +88,10 @@ func (sm *SyncManager) synchronise() { if peer == nil { return } + if ok:=sm.Switch().Peers().Has(peer.Key); !ok{ + log.Info("Peer disconnected") + sm.sw.StopPeerGracefully(peer) + } if bestHeight > sm.chain.BestBlockHeight() { log.Info("sync peer:", peer.Addr(), " height:", bestHeight) sm.blockKeeper.BlockRequestWorker(peer.Key, bestHeight) -- 2.11.0