OSDN Git Service

reorganize error code (#1133)
[bytom/bytom.git] / netsync / sync.go
index 2c1781a..7e3554e 100644 (file)
@@ -75,13 +75,16 @@ func (sm *SyncManager) syncer() {
 
 // synchronise tries to sync up our local block chain with a remote peer.
 func (sm *SyncManager) synchronise() {
-       log.Info("bk peer num:", sm.blockKeeper.peers.Len(), " sw peer num:", sm.sw.Peers().Size(), " ", sm.sw.Peers().List())
+       log.Debug("bk peer num:", sm.blockKeeper.peers.Len(), " sw peer num:", sm.sw.Peers().Size(), " ", sm.sw.Peers().List())
        // Make sure only one goroutine is ever allowed past this point at once
        if !atomic.CompareAndSwapInt32(&sm.synchronising, 0, 1) {
                log.Info("Synchronising ...")
                return
        }
        defer atomic.StoreInt32(&sm.synchronising, 0)
+       for len(sm.dropPeerCh) > 0 {
+               <-sm.dropPeerCh
+       }
 
        peer, bestHeight := sm.peers.BestPeer()
        // Short circuit if no peers are available