Stops us from consuming all the peers we store for no reason.
// Adds a Dialer for outgoing connections. All Dialers are used when attempting to connect to a
// given address for any Torrent.
func (cl *Client) AddDialer(d Dialer) {
+ cl.lock()
+ defer cl.unlock()
cl.dialers = append(cl.dialers, d)
+ for _, t := range cl.torrents {
+ t.openNewConns()
+ }
}
// Registers a Listener, and starts Accepting on it. You must Close Listeners provided this way
if len(t.halfOpen) >= t.maxHalfOpen() {
return
}
+ if len(t.cl.dialers) == 0 {
+ return
+ }
p := t.peers.PopMax()
t.initiateConn(p)
}