torrent.go | 6 +++--- diff --git a/torrent.go b/torrent.go index 6c4e8c2a8d3cdc36b92b376fb104e8540298afc7..aa7247cb368e051be54039f4be73ab36c1a425bb 100644 --- a/torrent.go +++ b/torrent.go @@ -441,7 +441,7 @@ fmt.Fprintf(w, "Trackers:\n") func() { tw := tabwriter.NewWriter(w, 0, 0, 2, ' ', 0) fmt.Fprintf(tw, " URL\tNext announce\tLast announce\n") - for _, ta := range slices.Sort(slices.FromElems(t.trackerAnnouncers), func(l, r *trackerScraper) bool { + for _, ta := range slices.Sort(slices.FromMapElems(t.trackerAnnouncers), func(l, r *trackerScraper) bool { return l.url < r.url }).([]*trackerScraper) { fmt.Fprintf(tw, " %s\n", ta.statusLine()) @@ -749,7 +749,7 @@ // for the longest. A bad connection is one that usually sends us unwanted // pieces, or has been in worser half of the established connections for more // than a minute. func (t *Torrent) worstBadConn() *connection { - wcs := slices.AsHeap(t.worstUnclosedConns(), worseConn) + wcs := slices.HeapInterface(t.worstUnclosedConns(), worseConn) for wcs.Len() != 0 { c := heap.Pop(wcs).(*connection) if c.UnwantedChunksReceived >= 6 && c.UnwantedChunksReceived > c.UsefulChunksReceived { @@ -1339,7 +1339,7 @@ t.cl.mu.Lock() defer t.cl.mu.Unlock() oldMax = t.maxEstablishedConns t.maxEstablishedConns = max - wcs := slices.AsHeap(append([]*connection(nil), t.conns...), worseConn) + wcs := slices.HeapInterface(append([]*connection(nil), t.conns...), worseConn) for len(t.conns) > t.maxEstablishedConns && wcs.Len() > 0 { t.dropConnection(wcs.Pop().(*connection)) }