682}
683
684func (f *blocksFetcher) hasSufficientBandwidth(peers []peer.ID, count uint64) []peer.ID {
685 filteredPeers := []peer.ID{}686 for _, p := range peers {
687 if uint64(f.rateLimiter.Remaining(p.String())) < count {
688 continue
An empty slice can be represented by nil
or an empty slice literal. They are
functionally equivalent — their len
and cap
are both zero — but the nil
slice is the preferred style. For more information about empty slices,
see Declaring Empty Slices.
package main
func foo() {
a := []int{}
}
package main
func foo() {
var a []int
}