diff --git a/eth/peerset.go b/eth/peerset.go index 5dfb73934a..c40a12bfa5 100644 --- a/eth/peerset.go +++ b/eth/peerset.go @@ -517,6 +517,9 @@ func (ps *peerSet) headPeers(num uint) []*ethPeer { list := make([]*ethPeer, 0, num) for _, p := range ps.peers { + if len(list) > int(num) { + break + } list = append(list, p) } return list