go cl.outgoingConnection(t, addr, peer.Source)
}
-func (cl *Client) dialTimeout(t *Torrent) time.Duration {
- cl.mu.Lock()
- pendingPeers := len(t.peers)
- cl.mu.Unlock()
- return reducedDialTimeout(nominalDialTimeout, cl.halfOpenLimit, pendingPeers)
-}
-
func (cl *Client) dialTCP(ctx context.Context, addr string) (c net.Conn, err error) {
d := net.Dialer{
// LocalAddr: cl.tcpListener.Addr(),
})
}
-func printConnPeerCounts(t *Torrent) {
- t.cl.mu.Lock()
- log.Println(len(t.conns), len(t.peers))
- t.cl.mu.Unlock()
-}
-
func totalConns(tts []*Torrent) (ret int) {
for _, tt := range tts {
tt.cl.mu.Lock()
cn.SetInterested(i)
}
-func (cn *connection) fillRequests() {
- cn.pieceRequestOrder.IterTyped(func(piece int) (more bool) {
- if cn.t.cl.config.Debug && cn.t.havePiece(piece) {
- panic(piece)
- }
- return cn.requestPiecePendingChunks(piece)
- })
-}
-
-func (c *connection) requestPiecePendingChunks(piece int) (again bool) {
- if !c.PeerHasPiece(piece) {
- return true
- }
- chunkIndices := c.t.pieces[piece].undirtiedChunkIndices().ToSortedSlice()
- return iter.ForPerm(len(chunkIndices), func(i int) bool {
- req := request{pp.Integer(piece), c.t.chunkIndexSpec(chunkIndices[i], piece)}
- return c.Request(req)
- })
-}
-
func undirtiedChunks(piece int, t *Torrent, f func(chunkSpec) bool) bool {
chunkIndices := t.pieces[piece].undirtiedChunkIndices().ToSortedSlice()
return iter.ForPerm(len(chunkIndices), func(i int) bool {
return
}
-func (r *Reader) tickleClient() {
- r.t.readersChanged()
-}
-
func (r *Reader) waitReadable(off int64) {
// We may have been sent back here because we were told we could read but
// it failed.
return
}
-func (t *Torrent) haveAllPieces() bool {
- if !t.haveInfo() {
- return false
- }
- return t.completedPieces.Len() == t.numPieces()
-}
-
func (t *Torrent) haveAnyPieces() bool {
for i := range t.pieces {
if t.pieceComplete(i) {