Unverified Commit 2a5314f7 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #126 from libp2p/feat/refactor

fixup for stream refactor
parents 9f9457ce 1b5b8ccf
4.1.3: QmPDE6hvHYmgQt8vVCxihao9HnvCtzRzS25bj9tYysCciT
4.2.0: QmYyonQoGb5Gw5VnGqgjKPPm1x3rY9QSquWCZqGKdiwuTw
......@@ -22,7 +22,7 @@ func (dht *IpfsDHT) handleNewStream(s inet.Stream) {
}
func (dht *IpfsDHT) handleNewMessage(s inet.Stream) {
defer s.Close()
defer inet.FullClose(s)
ctx := dht.Context()
cr := ctxio.NewReader(ctx, s) // ok to use. we defer close stream in this func
......@@ -233,7 +233,7 @@ func (ms *messageSender) SendMessage(ctx context.Context, pmes *pb.Message) erro
log.Event(ctx, "dhtSentMessage", ms.dht.self, ms.p, pmes)
if ms.singleMes > streamReuseTries {
ms.s.Close()
go inet.FullClose(ms.s)
ms.s = nil
} else if retry {
ms.singleMes++
......@@ -284,7 +284,7 @@ func (ms *messageSender) SendRequest(ctx context.Context, pmes *pb.Message) (*pb
log.Event(ctx, "dhtSentMessage", ms.dht.self, ms.p, pmes)
if ms.singleMes > streamReuseTries {
ms.s.Close()
go inet.FullClose(ms.s)
ms.s = nil
} else if retry {
ms.singleMes++
......
......@@ -18,11 +18,11 @@ import (
cid "github.com/ipfs/go-cid"
u "github.com/ipfs/go-ipfs-util"
kb "github.com/libp2p/go-libp2p-kbucket"
netutil "github.com/libp2p/go-libp2p-netutil"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
record "github.com/libp2p/go-libp2p-record"
routing "github.com/libp2p/go-libp2p-routing"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
ci "github.com/libp2p/go-testutil/ci"
travisci "github.com/libp2p/go-testutil/ci/travis"
......@@ -74,7 +74,7 @@ func (testValidator) Validate(_ string, b []byte) error {
func setupDHT(ctx context.Context, t *testing.T, client bool) *IpfsDHT {
d, err := New(
ctx,
bhost.New(netutil.GenSwarmNetwork(t, ctx)),
bhost.New(swarmt.GenSwarm(t, ctx, swarmt.OptDisableReuseport)),
opts.Client(client),
opts.NamespacedValidator("v", blankValidator{}),
)
......@@ -1088,12 +1088,12 @@ func TestGetSetPluggedProtocol(t *testing.T) {
opts.NamespacedValidator("v", blankValidator{}),
}
dhtA, err := New(ctx, bhost.New(netutil.GenSwarmNetwork(t, ctx)), os...)
dhtA, err := New(ctx, bhost.New(swarmt.GenSwarm(t, ctx, swarmt.OptDisableReuseport)), os...)
if err != nil {
t.Fatal(err)
}
dhtB, err := New(ctx, bhost.New(netutil.GenSwarmNetwork(t, ctx)), os...)
dhtB, err := New(ctx, bhost.New(swarmt.GenSwarm(t, ctx, swarmt.OptDisableReuseport)), os...)
if err != nil {
t.Fatal(err)
}
......@@ -1120,7 +1120,7 @@ func TestGetSetPluggedProtocol(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
dhtA, err := New(ctx, bhost.New(netutil.GenSwarmNetwork(t, ctx)), []opts.Option{
dhtA, err := New(ctx, bhost.New(swarmt.GenSwarm(t, ctx, swarmt.OptDisableReuseport)), []opts.Option{
opts.Protocols("/esh/dht"),
opts.Client(false),
opts.NamespacedValidator("v", blankValidator{}),
......@@ -1129,7 +1129,7 @@ func TestGetSetPluggedProtocol(t *testing.T) {
t.Fatal(err)
}
dhtB, err := New(ctx, bhost.New(netutil.GenSwarmNetwork(t, ctx)), []opts.Option{
dhtB, err := New(ctx, bhost.New(swarmt.GenSwarm(t, ctx, swarmt.OptDisableReuseport)), []opts.Option{
opts.Protocols("/lsr/dht"),
opts.Client(false),
opts.NamespacedValidator("v", blankValidator{}),
......
......@@ -53,7 +53,7 @@ func (nn *netNotifiee) testConnection(v inet.Conn) {
// Connection error
return
}
defer s.Close()
defer inet.FullClose(s)
selected, err := mstream.SelectOneOf(dht.protocolStrs(), s)
if err != nil {
......
......@@ -54,9 +54,9 @@
},
{
"author": "whyrusleeping",
"hash": "QmdeiKhUy1TVGBaKxt7y1QmBDLBdisSrLJ1x58Eoj4PXUh",
"hash": "QmZb7hAgQEhW9dBbzBudU39gCeD4zbe6xafD52LUuF4cUN",
"name": "go-libp2p-peerstore",
"version": "1.4.17"
"version": "1.4.18"
},
{
"author": "whyrusleeping",
......@@ -78,15 +78,15 @@
},
{
"author": "whyrusleeping",
"hash": "QmVn1WR5woqFfydU7aUpjKeF514oAd1RvvBCcbuUiP8bm7",
"hash": "QmXDYDP3s1e1LLJNrxWsCZfaKvbLAuKBYj4am86voY2STT",
"name": "go-libp2p-kbucket",
"version": "2.1.18"
"version": "2.2.0"
},
{
"author": "whyrusleeping",
"hash": "QmUHRKTeaoASDvDj7cTAXsmjAY7KQ13ErtzkQHZQq6uFUz",
"hash": "QmXijJ3T9MjB2v8xpFDoEX6FqR9u8PkJkzu49TgwJ8Ndr5",
"name": "go-libp2p-routing",
"version": "2.3.0"
"version": "2.4.0"
},
{
"author": "whyrusleeping",
......@@ -108,21 +108,21 @@
},
{
"author": "whyrusleeping",
"hash": "QmaSfSMvc1VPZ8JbMponFs4WHvF9FgEruF56opm5E1RgQA",
"hash": "QmdHyfNVTZ5VtUx4Xz23z8wtnioSrFQ28XSfpVkdhQBkGA",
"name": "go-libp2p-host",
"version": "2.1.8"
"version": "3.0.0"
},
{
"author": "whyrusleeping",
"hash": "QmY6iAoG9DVgZwh5ZRcQEpa2uErAe1Hbei8qXPCjpDS9Ge",
"hash": "QmRvoAami8AAf5Yy6jcPq5KqQT1ZCaoi9dF1vdKAghmq9X",
"name": "go-libp2p",
"version": "5.0.21"
"version": "6.0.0"
},
{
"author": "whyrusleeping",
"hash": "QmXoz9o2PT3tEzf7hicegwex5UgVP54n3k82K7jrWFyN86",
"hash": "QmYj8wdn5sZEHX2XMDWGBvcXJNdzVbaVpHmXvhHBVZepen",
"name": "go-libp2p-net",
"version": "2.0.7"
"version": "3.0.0"
},
{
"author": "whyrusleeping",
......@@ -136,12 +136,6 @@
"name": "go-multistream",
"version": "0.3.7"
},
{
"author": "whyrusleeping",
"hash": "Qma2UuHusnaFV24DgeZ5hyrM9uc4UdyVaZbtn2FQsPRhES",
"name": "go-libp2p-netutil",
"version": "0.3.13"
},
{
"author": "multiformats",
"hash": "QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb",
......@@ -159,6 +153,12 @@
"hash": "QmWFAMPqsEyUX7gDUsRVmMWz59FxSpJ1b2v6bJ1yYzo7jY",
"name": "go-base58-fast",
"version": "0.1.1"
},
{
"author": "whyrusleeping",
"hash": "QmPzT3rJnSP8VFP1kw7Ly7HP8AprKNZtwLHXHnxfVSbWT3",
"name": "go-libp2p-swarm",
"version": "3.0.0"
}
],
"gxVersion": "0.4.0",
......@@ -166,6 +166,6 @@
"license": "MIT",
"name": "go-libp2p-kad-dht",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "4.1.3"
"version": "4.2.0"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment