Skip to content

Commit 11937be

Browse files
committedJul 11, 2015
moved util/ctx to github.com/jbenet/go-context
License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
1 parent 8331121 commit 11937be

File tree

9 files changed

+103
-53
lines changed

9 files changed

+103
-53
lines changed
 

‎Godeps/Godeps.json

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Godeps/_workspace/src/github.com/jbenet/go-context/frac/fracctx.go

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎util/ctx/fracctx_test.go ‎Godeps/_workspace/src/github.com/jbenet/go-context/frac/fracctx_test.go

+4-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎util/ctx/ctxio.go ‎Godeps/_workspace/src/github.com/jbenet/go-context/io/ctxio.go

+11-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎util/ctx/ctxio_test.go ‎Godeps/_workspace/src/github.com/jbenet/go-context/io/ctxio_test.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎diagnostics/diag.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ import (
1313

1414
ggio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io"
1515
proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
16+
ctxio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-context/io"
1617
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
17-
1818
pb "github.com/ipfs/go-ipfs/diagnostics/pb"
1919
host "github.com/ipfs/go-ipfs/p2p/host"
2020
inet "github.com/ipfs/go-ipfs/p2p/net"
2121
peer "github.com/ipfs/go-ipfs/p2p/peer"
2222
protocol "github.com/ipfs/go-ipfs/p2p/protocol"
2323
util "github.com/ipfs/go-ipfs/util"
24-
ctxutil "github.com/ipfs/go-ipfs/util/ctx"
2524
)
2625

2726
var log = util.Logger("diagnostics")
@@ -209,8 +208,8 @@ func (d *Diagnostics) getDiagnosticFromPeer(ctx context.Context, p peer.ID, pmes
209208
return nil, err
210209
}
211210

212-
cr := ctxutil.NewReader(ctx, s) // ok to use. we defer close stream in this func
213-
cw := ctxutil.NewWriter(ctx, s) // ok to use. we defer close stream in this func
211+
cr := ctxio.NewReader(ctx, s) // ok to use. we defer close stream in this func
212+
cw := ctxio.NewWriter(ctx, s) // ok to use. we defer close stream in this func
214213
r := ggio.NewDelimitedReader(cr, inet.MessageSizeMax)
215214
w := ggio.NewDelimitedWriter(cw)
216215

@@ -267,8 +266,8 @@ func newMessage(diagID string) *pb.Message {
267266

268267
func (d *Diagnostics) HandleMessage(ctx context.Context, s inet.Stream) error {
269268

270-
cr := ctxutil.NewReader(ctx, s)
271-
cw := ctxutil.NewWriter(ctx, s)
269+
cr := ctxio.NewReader(ctx, s)
270+
cw := ctxio.NewWriter(ctx, s)
272271
r := ggio.NewDelimitedReader(cr, inet.MessageSizeMax) // maxsize
273272
w := ggio.NewDelimitedWriter(cw)
274273

‎routing/dht/dht_net.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import (
44
"errors"
55
"time"
66

7+
ggio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io"
8+
ctxio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-context/io"
9+
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
710
inet "github.com/ipfs/go-ipfs/p2p/net"
811
peer "github.com/ipfs/go-ipfs/p2p/peer"
912
pb "github.com/ipfs/go-ipfs/routing/dht/pb"
10-
ctxutil "github.com/ipfs/go-ipfs/util/ctx"
11-
12-
ggio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io"
13-
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
1413
)
1514

1615
// handleNewStream implements the inet.StreamHandler
@@ -22,8 +21,8 @@ func (dht *IpfsDHT) handleNewMessage(s inet.Stream) {
2221
defer s.Close()
2322

2423
ctx := dht.Context()
25-
cr := ctxutil.NewReader(ctx, s) // ok to use. we defer close stream in this func
26-
cw := ctxutil.NewWriter(ctx, s) // ok to use. we defer close stream in this func
24+
cr := ctxio.NewReader(ctx, s) // ok to use. we defer close stream in this func
25+
cw := ctxio.NewWriter(ctx, s) // ok to use. we defer close stream in this func
2726
r := ggio.NewDelimitedReader(cr, inet.MessageSizeMax)
2827
w := ggio.NewDelimitedWriter(cw)
2928
mPeer := s.Conn().RemotePeer()
@@ -78,8 +77,8 @@ func (dht *IpfsDHT) sendRequest(ctx context.Context, p peer.ID, pmes *pb.Message
7877
}
7978
defer s.Close()
8079

81-
cr := ctxutil.NewReader(ctx, s) // ok to use. we defer close stream in this func
82-
cw := ctxutil.NewWriter(ctx, s) // ok to use. we defer close stream in this func
80+
cr := ctxio.NewReader(ctx, s) // ok to use. we defer close stream in this func
81+
cw := ctxio.NewWriter(ctx, s) // ok to use. we defer close stream in this func
8382
r := ggio.NewDelimitedReader(cr, inet.MessageSizeMax)
8483
w := ggio.NewDelimitedWriter(cw)
8584

@@ -116,7 +115,7 @@ func (dht *IpfsDHT) sendMessage(ctx context.Context, p peer.ID, pmes *pb.Message
116115
}
117116
defer s.Close()
118117

119-
cw := ctxutil.NewWriter(ctx, s) // ok to use. we defer close stream in this func
118+
cw := ctxio.NewWriter(ctx, s) // ok to use. we defer close stream in this func
120119
w := ggio.NewDelimitedWriter(cw)
121120

122121
if err := w.WriteMsg(pmes); err != nil {

‎routing/dht/records.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package dht
33
import (
44
"fmt"
55

6+
ctxfrac "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-context/frac"
67
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
78
ci "github.com/ipfs/go-ipfs/p2p/crypto"
89
peer "github.com/ipfs/go-ipfs/p2p/peer"
910
routing "github.com/ipfs/go-ipfs/routing"
1011
pb "github.com/ipfs/go-ipfs/routing/dht/pb"
1112
record "github.com/ipfs/go-ipfs/routing/record"
12-
ctxutil "github.com/ipfs/go-ipfs/util/ctx"
1313
)
1414

1515
func (dht *IpfsDHT) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error) {
@@ -22,7 +22,7 @@ func (dht *IpfsDHT) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, err
2222
}
2323

2424
// ok, try the node itself. if they're overwhelmed or slow we can move on.
25-
ctxT, cancelFunc := ctxutil.WithDeadlineFraction(ctx, 0.3)
25+
ctxT, cancelFunc := ctxfrac.WithDeadlineFraction(ctx, 0.3)
2626
defer cancelFunc()
2727
if pk, err := dht.getPublicKeyFromNode(ctx, p); err == nil {
2828
err := dht.peerstore.AddPubKey(p, pk)

‎util/ctx/fracctx.go

-22
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.