func (l *PeerList) Remove(peer *Peer) {
	for i := range l.peers {
		if l.peers[i] == peer {
			l.peers = append(l.peers[:i], l.peers[i+1:]...)
			return
		}
	}
	panic("peer not in list")
}
Remove removes the given peer from the list.
package node
import (
	"errors"
	"net"
	"github.com/alexbakker/gonano/nano/crypto/random"
)
var (
	ErrMaxPeers   = errors.New("max amount of peers reached")
	ErrPeerExists = errors.New("this peer already exists in the list")
)
type PeerList struct {
	peers []*Peer
	max   int
}
func NewPeerList(max int) *PeerList {
	return &PeerList{max: max}
}
func (l *PeerList) Add(addr *net.UDPAddr) (*Peer, error) {
	if l.Full() {
		return nil, ErrMaxPeers
	}
	if l.Get(addr) != nil {
		return nil, ErrPeerExists
	}
	peer := &Peer{Addr: addr}
	l.peers = append(l.peers, peer)
	return peer, nil
}
func (l *PeerList) Get(addr *net.UDPAddr) *Peer {
	for _, peer := range l.peers {
		if peer.Addr.IP.Equal(addr.IP) && peer.Addr.Port == addr.Port {
			return peer
		}
	}
	return nil
}