return false
}
-func (t *torrent) worstConnsHeap() (wcs *worstConns) {
+func (t *torrent) worstConnsHeap(cl *Client) (wcs *worstConns) {
wcs = &worstConns{
- c: append([]*connection{}, t.Conns...),
- t: t,
+ c: append([]*connection{}, t.Conns...),
+ t: t,
+ cl: cl,
}
heap.Init(wcs)
return
return
}
-func (t *torrent) writeStatus(w io.Writer) {
+func (t *torrent) writeStatus(w io.Writer, cl *Client) {
fmt.Fprintf(w, "Infohash: %x\n", t.InfoHash)
fmt.Fprintf(w, "Metadata length: %d\n", t.metadataSize())
fmt.Fprintf(w, "Metadata have: ")
fmt.Fprintf(w, "Half open: %d\n", len(t.HalfOpen))
fmt.Fprintf(w, "Active peers: %d\n", len(t.Conns))
sort.Sort(&worstConns{
- c: t.Conns,
- t: t,
+ c: t.Conns,
+ t: t,
+ cl: cl,
})
for _, c := range t.Conns {
c.WriteStatus(w, t)
}
func (t *torrent) urgentChunkInPiece(piece int) bool {
+ p := pp.Integer(piece)
for req := range t.urgent {
- if int(req.Index) == piece {
+ if req.Index == p {
return true
}
}