func (s *Server) handlePeerRequest(conn *Conn, msg *protocol.Message) { // TODO(d4l3k): Handle keyspace check. req := msg.GetPeerRequest() var peers []*protocol.Peer for id, v := range s.Peers { if conn.Peer.Id == id || v == nil { continue } peers = append(peers, v.Peer) if req.Limit > 0 && int32(len(peers)) >= req.Limit { break } } err := conn.Send(&protocol.Message{Message: &protocol.Message_PeerNotify{ PeerNotify: &protocol.PeerNotify{ Peers: peers, }}}) if err != nil { log.Printf("ERR sending PeerNotify: %s", err) } }