]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Rename Torrent.{add,delete}Connection
authorMatt Joiner <anacrolix@gmail.com>
Mon, 10 May 2021 06:53:08 +0000 (16:53 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 14 May 2021 05:39:01 +0000 (15:39 +1000)
client.go
pexconn_test.go
torrent.go

index 1419958bd079feeade4478c8b2d76b445f8b33e1..9506cfd2adfa11febd46fec1913d8a64b6270578 100644 (file)
--- a/client.go
+++ b/client.go
@@ -766,7 +766,7 @@ func (cl *Client) outgoingConnection(t *Torrent, addr PeerRemoteAddr, ps PeerSou
        c, err := cl.establishOutgoingConn(t, addr)
        cl.lock()
        defer cl.unlock()
-       // Don't release lock between here and addConnection, unless it's for
+       // Don't release lock between here and addPeerConn, unless it's for
        // failure.
        cl.noLongerHalfOpen(t, addr.String())
        if err != nil {
@@ -951,7 +951,7 @@ func (cl *Client) runHandshookConn(c *PeerConn, t *Torrent) error {
        if connIsIpv6(c.conn) {
                torrent.Add("completed handshake over ipv6", 1)
        }
-       if err := t.addConnection(c); err != nil {
+       if err := t.addPeerConn(c); err != nil {
                return fmt.Errorf("adding connection: %w", err)
        }
        defer t.dropConnection(c)
index 0b78b70242f503605edb095db5112dcd751c3974..a3ff1d02dbbe3b36ea772b18183f96a94abe2b82 100644 (file)
@@ -23,7 +23,7 @@ func TestPexConnState(t *testing.T) {
        c.PeerExtensionIDs[pp.ExtensionNamePex] = pexExtendedId
        c.writerCond.L.Lock()
        c.setTorrent(torrent)
-       torrent.addConnection(c)
+       torrent.addPeerConn(c)
 
        c.pex.Init(c)
        require.True(t, c.pex.IsEnabled(), "should get enabled")
index 32b7e5fda1a74e67b0fa24c8f304d6e9541e7aad..78d0f45850153d838c861dddc92e0f5b5daf53f4 100644 (file)
@@ -1283,7 +1283,7 @@ func (t *Torrent) SetInfoBytes(b []byte) (err error) {
 }
 
 // Returns true if connection is removed from torrent.Conns.
-func (t *Torrent) deleteConnection(c *PeerConn) (ret bool) {
+func (t *Torrent) deletePeerConn(c *PeerConn) (ret bool) {
        if !c.closed.IsSet() {
                panic("connection is not closed")
                // There are behaviours prevented by the closed state that will fail
@@ -1325,7 +1325,7 @@ func (t *Torrent) assertNoPendingRequests() {
 func (t *Torrent) dropConnection(c *PeerConn) {
        t.cl.event.Broadcast()
        c.close()
-       if t.deleteConnection(c) {
+       if t.deletePeerConn(c) {
                t.openNewConns()
        }
 }
@@ -1665,7 +1665,7 @@ func (t *Torrent) reconcileHandshakeStats(c *PeerConn) {
 }
 
 // Returns true if the connection is added.
-func (t *Torrent) addConnection(c *PeerConn) (err error) {
+func (t *Torrent) addPeerConn(c *PeerConn) (err error) {
        defer func() {
                if err == nil {
                        torrent.Add("added connections", 1)
@@ -1683,7 +1683,7 @@ func (t *Torrent) addConnection(c *PeerConn) (err error) {
                }
                if left, ok := c.hasPreferredNetworkOver(c0); ok && left {
                        c0.close()
-                       t.deleteConnection(c0)
+                       t.deletePeerConn(c0)
                } else {
                        return errors.New("existing connection preferred")
                }
@@ -1694,7 +1694,7 @@ func (t *Torrent) addConnection(c *PeerConn) (err error) {
                        return errors.New("don't want conns")
                }
                c.close()
-               t.deleteConnection(c)
+               t.deletePeerConn(c)
        }
        if len(t.conns) >= t.maxEstablishedConns {
                panic(len(t.conns))