Merge pull request #385 from harmony-one/handle_end_of_peers

Handle peer channel closure gracefully
pull/388/head
Eugene Kim 6 years ago committed by GitHub
commit 4b41338ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      api/service/discovery/service.go

@ -80,7 +80,11 @@ func (s *Service) StopService() {
func (s *Service) foundPeers() {
for {
select {
case peer := <-s.peerChan:
case peer, ok := <-s.peerChan:
if !ok {
log.Debug("end of info", "peer", peer.ID)
return
}
if peer.ID != s.Host.GetP2PHost().ID() && len(peer.ID) > 0 {
log.Debug("Found Peer", "peer", peer.ID, "addr", peer.Addrs, "len", len(peer.ID))
p := p2p.Peer{PeerID: peer.ID, Addrs: peer.Addrs}

Loading…
Cancel
Save