code: func (t *Torrent) addConnection(c *connection) (err error) {
  	defer func() {
  		if err == nil {
  			torrent.Add("added connections", 1)
  		}
  	}()
  	if t.closed.IsSet() {
  		return errors.New("torrent closed")
  	}
  	for c0 := range t.conns {
  		if c.PeerID != c0.PeerID {
  			continue
  		}
  		if !t.cl.config.dropDuplicatePeerIds {
  			continue
  		}
  		if left, ok := c.hasPreferredNetworkOver(c0); ok && left {
  			c0.Close()
  			t.deleteConnection(c0)
  		} else {
  			return errors.New("existing connection preferred")
  		}
  	}
  	if len(t.conns) >= t.maxEstablishedConns {
  		c := t.worstBadConn()
  		if c == nil {
  			return errors.New("don't want conns")
  		}
  		c.Close()
  		t.deleteConnection(c)
  	}
  	if len(t.conns) >= t.maxEstablishedConns {
  		panic(len(t.conns))
  	}
  	t.conns[c] = struct{}{}
  	return nil
  }
docs: // Returns true if the connection is added.