Skip to content

Commit

Permalink
Merge pull request #126 from libp2p/feat/use-stdlib-ctx
Browse files Browse the repository at this point in the history
switch to using stdlib context package
  • Loading branch information
whyrusleeping authored Oct 3, 2016
2 parents 87b0e20 + 4dd30d8 commit b6aff36
Show file tree
Hide file tree
Showing 40 changed files with 41 additions and 46 deletions.
2 changes: 1 addition & 1 deletion examples/hosts/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"flag"
"fmt"
"io/ioutil"
Expand All @@ -17,7 +18,6 @@ import (
testutil "github.com/libp2p/go-libp2p/testutil"

ma "github.com/jbenet/go-multiaddr"
context "golang.org/x/net/context"
)

// create a 'Host' with a random peer to listen on the given address
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/basic/basic_host.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package basichost

import (
"context"
"io"
"time"

Expand All @@ -15,7 +16,6 @@ import (
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
relay "github.com/libp2p/go-libp2p/p2p/protocol/relay"
context "golang.org/x/net/context"

msmux "github.com/whyrusleeping/go-multistream"
)
Expand Down
3 changes: 1 addition & 2 deletions p2p/host/basic/basic_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package basichost_test

import (
"bytes"
"context"
"io"
"testing"
"time"
Expand All @@ -10,8 +11,6 @@ import (
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"

context "golang.org/x/net/context"
)

func TestHostSimple(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/basic/natmgr.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package basichost

import (
"context"
"sync"

lgbl "github.com/ipfs/go-libp2p-loggables"
ma "github.com/jbenet/go-multiaddr"
goprocess "github.com/jbenet/goprocess"
inat "github.com/libp2p/go-libp2p/p2p/nat"
inet "github.com/libp2p/go-libp2p/p2p/net"
context "golang.org/x/net/context"
)

// natManager takes care of adding + removing port mappings to the nat.
Expand Down
3 changes: 2 additions & 1 deletion p2p/host/host.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package host

import (
"context"

peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
logging "github.com/ipfs/go-log"
Expand All @@ -9,7 +11,6 @@ import (
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
msmux "github.com/whyrusleeping/go-multistream"
context "golang.org/x/net/context"
)

var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/host")
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/routed/routed.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package routedhost

import (
"context"
"fmt"
"time"

Expand All @@ -13,7 +14,6 @@ import (
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
context "golang.org/x/net/context"

msmux "github.com/whyrusleeping/go-multistream"
)
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/conn/conn.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package conn

import (
"context"
"fmt"
"io"
"net"
Expand All @@ -14,7 +15,6 @@ import (
mpool "github.com/jbenet/go-msgio/mpool"
ma "github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-multiaddr-net"
context "golang.org/x/net/context"
)

var log = logging.Logger("conn")
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/conn/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"testing"
"time"

"context"
msgio "github.com/jbenet/go-msgio"
travis "github.com/libp2p/go-libp2p/testutil/ci/travis"
context "golang.org/x/net/context"
)

func msgioWrap(c Conn) msgio.ReadWriter {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/conn/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"time"

"context"
ci "github.com/ipfs/go-libp2p-crypto"
lgbl "github.com/ipfs/go-libp2p-loggables"
peer "github.com/ipfs/go-libp2p-peer"
Expand All @@ -14,7 +15,6 @@ import (
transport "github.com/libp2p/go-libp2p-transport"
addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr"
msmux "github.com/whyrusleeping/go-multistream"
context "golang.org/x/net/context"
)

type WrapFunc func(transport.Conn) transport.Conn
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/conn/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
tu "github.com/libp2p/go-libp2p/testutil"
tcpt "github.com/libp2p/go-tcp-transport"

"context"
ma "github.com/jbenet/go-multiaddr"
msmux "github.com/whyrusleeping/go-multistream"
grc "github.com/whyrusleeping/gorocheck"
context "golang.org/x/net/context"
)

func goroFilter(r *grc.Goroutine) bool {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/conn/listen.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package conn

import (
"context"
"fmt"
"io"
"net"
Expand All @@ -16,7 +17,6 @@ import (
transport "github.com/libp2p/go-libp2p-transport"
filter "github.com/libp2p/go-libp2p/p2p/net/filter"
msmux "github.com/whyrusleeping/go-multistream"
context "golang.org/x/net/context"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/conn/secure_conn.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package conn

import (
"context"
"errors"
"net"
"time"
Expand All @@ -9,7 +10,6 @@ import (
peer "github.com/ipfs/go-libp2p-peer"
secio "github.com/ipfs/go-libp2p-secio"
ma "github.com/jbenet/go-multiaddr"
context "golang.org/x/net/context"
)

// secureConn wraps another Conn object with an encrypted channel.
Expand Down
3 changes: 1 addition & 2 deletions p2p/net/conn/secure_conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package conn

import (
"bytes"
"context"
"runtime"
"sync"
"testing"
"time"

ic "github.com/ipfs/go-libp2p-crypto"
travis "github.com/libp2p/go-libp2p/testutil/ci/travis"

context "golang.org/x/net/context"
)

func upgradeToSecureConn(t *testing.T, ctx context.Context, sk ic.PrivKey, c Conn) (Conn, error) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/interface.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net

import (
"context"
"io"

peer "github.com/ipfs/go-libp2p-peer"
Expand All @@ -9,7 +10,6 @@ import (
"github.com/jbenet/goprocess"
conn "github.com/libp2p/go-libp2p/p2p/net/conn"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
context "golang.org/x/net/context"
)

// MessageSizeMax is a soft (recommended) maximum for network messages.
Expand Down
3 changes: 2 additions & 1 deletion p2p/net/mock/mock.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package mocknet

import (
"context"

logging "github.com/ipfs/go-log"
context "golang.org/x/net/context"
)

var log = logging.Logger("mocknet")
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/mock/mock_net.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
p2putil "github.com/libp2p/go-libp2p/p2p/test/util"
testutil "github.com/libp2p/go-libp2p/testutil"

"context"
ic "github.com/ipfs/go-libp2p-crypto"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
ma "github.com/jbenet/go-multiaddr"
"github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context"
context "golang.org/x/net/context"
)

// mocknet implements mocknet.Mocknet
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/mock/mock_notif_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package mocknet

import (
"context"
"testing"
"time"

peer "github.com/ipfs/go-libp2p-peer"
ma "github.com/jbenet/go-multiaddr"
inet "github.com/libp2p/go-libp2p/p2p/net"
context "golang.org/x/net/context"
)

func TestNotifications(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/mock/mock_peernet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

inet "github.com/libp2p/go-libp2p/p2p/net"

"context"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
ma "github.com/jbenet/go-multiaddr"
"github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context"
context "golang.org/x/net/context"
)

// peernet implements inet.Network
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
testutil "github.com/libp2p/go-libp2p/testutil"

"context"
detectrace "github.com/jbenet/go-detect-race"
context "golang.org/x/net/context"
)

func randPeer(t *testing.T) peer.ID {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/addr/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package addrutil
import (
"fmt"

"context"
logging "github.com/ipfs/go-log"
ma "github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-multiaddr-net"
context "golang.org/x/net/context"

_ "github.com/whyrusleeping/ws-transport"
)
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
testutil "github.com/libp2p/go-libp2p/testutil"
ci "github.com/libp2p/go-libp2p/testutil/ci"

"context"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
ma "github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-multiaddr-net"
context "golang.org/x/net/context"
)

func closeSwarms(swarms []*Swarm) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/peers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package swarm
import (
"testing"

"context"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
ma "github.com/jbenet/go-multiaddr"
context "golang.org/x/net/context"
)

func TestPeers(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/simul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (

ci "github.com/libp2p/go-libp2p/testutil/ci"

"context"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
ma "github.com/jbenet/go-multiaddr"
context "golang.org/x/net/context"
)

func TestSimultOpen(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr"
testutil "github.com/libp2p/go-libp2p/testutil"

"context"
pstore "github.com/ipfs/go-libp2p-peerstore"
ma "github.com/jbenet/go-multiaddr"
context "golang.org/x/net/context"
)

func TestFilterAddrs(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
inet "github.com/libp2p/go-libp2p/p2p/net"
conn "github.com/libp2p/go-libp2p/p2p/net/conn"

"context"
ic "github.com/ipfs/go-libp2p-crypto"
peer "github.com/ipfs/go-libp2p-peer"
ma "github.com/jbenet/go-multiaddr"
ps "github.com/jbenet/go-peerstream"
context "golang.org/x/net/context"
)

// Conn is a simple wrapper around a ps.Conn that also exposes
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package swarm
import (
"fmt"

"context"
lgbl "github.com/ipfs/go-libp2p-loggables"
ma "github.com/jbenet/go-multiaddr"
ps "github.com/jbenet/go-peerstream"
transport "github.com/libp2p/go-libp2p-transport"
mconn "github.com/libp2p/go-libp2p/p2p/metrics/conn"
inet "github.com/libp2p/go-libp2p/p2p/net"
conn "github.com/libp2p/go-libp2p/p2p/net/conn"
context "golang.org/x/net/context"
)

func (s *Swarm) AddListenAddr(a ma.Multiaddr) error {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_net.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
inet "github.com/libp2p/go-libp2p/p2p/net"

"context"
ma "github.com/jbenet/go-multiaddr"
"github.com/jbenet/goprocess"
context "golang.org/x/net/context"
)

// Network implements the inet.Network interface.
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

inet "github.com/libp2p/go-libp2p/p2p/net"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
context "golang.org/x/net/context"
"context"
)

// TestConnectednessCorrect starts a few networks, connects a few
Expand Down
Loading

0 comments on commit b6aff36

Please sign in to comment.