]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Use half open limit directly from Config
authorMatt Joiner <anacrolix@gmail.com>
Tue, 10 Jul 2018 02:23:00 +0000 (12:23 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 10 Jul 2018 02:23:00 +0000 (12:23 +1000)
client.go
torrent.go

index 3c8cc28a51926aac619617cd6808d93754274056..975106f40a1a505888f8480cfaa98cd129326fbc 100644 (file)
--- a/client.go
+++ b/client.go
@@ -48,7 +48,6 @@ type Client struct {
        config *ClientConfig
        logger *log.Logger
 
-       halfOpenLimit  int
        peerID         PeerID
        defaultStorage *storage.Client
        onClose        []func()
@@ -180,7 +179,6 @@ func NewClient(cfg *ClientConfig) (cl *Client, err error) {
                }
        }()
        cl = &Client{
-               halfOpenLimit:     cfg.HalfOpenConnsPerTorrent,
                config:            cfg,
                dopplegangerAddrs: make(map[string]struct{}),
                torrents:          make(map[metainfo.Hash]*Torrent),
index 29363058debd86bd819b69a4a25bb46066c22e68..0360c514471fb922a218ccf87cece50a98de7021 100644 (file)
@@ -1059,7 +1059,7 @@ func (t *Torrent) maxHalfOpen() int {
        extraIncoming := int64(t.numReceivedConns() - t.maxEstablishedConns/2)
        // We want to allow some experimentation with new peers, and to try to
        // upset an oversupply of received connections.
-       return int(min(max(5, extraIncoming)+establishedHeadroom, int64(t.cl.halfOpenLimit)))
+       return int(min(max(5, extraIncoming)+establishedHeadroom, int64(t.cl.config.HalfOpenConnsPerTorrent)))
 }
 
 func (t *Torrent) openNewConns() {
@@ -1792,5 +1792,5 @@ func (t *Torrent) pieceQueuedForHash(i pieceIndex) bool {
 }
 
 func (t *Torrent) dialTimeout() time.Duration {
-       return reducedDialTimeout(t.cl.config.MinDialTimeout, t.cl.config.NominalDialTimeout, t.cl.halfOpenLimit, t.peers.Len())
+       return reducedDialTimeout(t.cl.config.MinDialTimeout, t.cl.config.NominalDialTimeout, t.cl.config.HalfOpenConnsPerTorrent, t.peers.Len())
 }