Skip to content

Commit

Permalink
clean up reusedial and remove go-libp2p-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Mar 22, 2017
1 parent cfef65c commit 59530f2
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions p2p/transport/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

logging "github.com/ipfs/go-log"
reuseport "github.com/jbenet/go-reuseport"
lgbl "github.com/libp2p/go-libp2p-loggables"
tpt "github.com/libp2p/go-libp2p-transport"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
Expand Down Expand Up @@ -202,33 +201,27 @@ func (d *tcpDialer) DialContext(ctx context.Context, raddr ma.Multiaddr) (tpt.Co
}

func (d *tcpDialer) reuseDial(ctx context.Context, raddr ma.Multiaddr) (manet.Conn, error) {
logdial := lgbl.Dial("conn", "", "", d.laddr, raddr)
rpev := log.EventBegin(ctx, "tptDialReusePort", logdial)

network, netraddr, err := manet.DialArgs(raddr)
if err != nil {
return nil, err
}

_ = ctx // TODO: implement DialContext in reuseport
rpev := log.EventBegin(ctx, "tptDialReusePort", logging.LoggableMap{
"raddr": raddr,
})

con, err := d.rd.DialContext(ctx, network, netraddr)
if err == nil {
logdial["reuseport"] = "success"
rpev.Done()
return manet.WrapNetConn(con)
}
rpev.SetError(err)
rpev.Done()

if !ReuseErrShouldRetry(err) {
logdial["reuseport"] = "failure"
logdial["error"] = err
rpev.Done()
return nil, err
}

logdial["reuseport"] = "retry"
logdial["error"] = err
rpev.Done()

return d.madialer.DialContext(ctx, raddr)
}

Expand Down

0 comments on commit 59530f2

Please sign in to comment.