Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
0e59a511
Commit
0e59a511
authored
Jul 10, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved util/ctx to github.com/jbenet/go-context
License: MIT Signed-off-by:
Juan Batiz-Benet
<
juan@benet.ai
>
parent
41246638
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
11 deletions
+10
-11
dht_net.go
dht_net.go
+8
-9
records.go
records.go
+2
-2
No files found.
dht_net.go
View file @
0e59a511
...
...
@@ -4,13 +4,12 @@ import (
"errors"
"time"
ggio
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io"
ctxio
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-context/io"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
inet
"github.com/ipfs/go-ipfs/p2p/net"
peer
"github.com/ipfs/go-ipfs/p2p/peer"
pb
"github.com/ipfs/go-ipfs/routing/dht/pb"
ctxutil
"github.com/ipfs/go-ipfs/util/ctx"
ggio
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
)
// handleNewStream implements the inet.StreamHandler
...
...
@@ -22,8 +21,8 @@ func (dht *IpfsDHT) handleNewMessage(s inet.Stream) {
defer
s
.
Close
()
ctx
:=
dht
.
Context
()
cr
:=
ctx
util
.
NewReader
(
ctx
,
s
)
// ok to use. we defer close stream in this func
cw
:=
ctx
util
.
NewWriter
(
ctx
,
s
)
// ok to use. we defer close stream in this func
cr
:=
ctx
io
.
NewReader
(
ctx
,
s
)
// ok to use. we defer close stream in this func
cw
:=
ctx
io
.
NewWriter
(
ctx
,
s
)
// ok to use. we defer close stream in this func
r
:=
ggio
.
NewDelimitedReader
(
cr
,
inet
.
MessageSizeMax
)
w
:=
ggio
.
NewDelimitedWriter
(
cw
)
mPeer
:=
s
.
Conn
()
.
RemotePeer
()
...
...
@@ -78,8 +77,8 @@ func (dht *IpfsDHT) sendRequest(ctx context.Context, p peer.ID, pmes *pb.Message
}
defer
s
.
Close
()
cr
:=
ctx
util
.
NewReader
(
ctx
,
s
)
// ok to use. we defer close stream in this func
cw
:=
ctx
util
.
NewWriter
(
ctx
,
s
)
// ok to use. we defer close stream in this func
cr
:=
ctx
io
.
NewReader
(
ctx
,
s
)
// ok to use. we defer close stream in this func
cw
:=
ctx
io
.
NewWriter
(
ctx
,
s
)
// ok to use. we defer close stream in this func
r
:=
ggio
.
NewDelimitedReader
(
cr
,
inet
.
MessageSizeMax
)
w
:=
ggio
.
NewDelimitedWriter
(
cw
)
...
...
@@ -116,7 +115,7 @@ func (dht *IpfsDHT) sendMessage(ctx context.Context, p peer.ID, pmes *pb.Message
}
defer
s
.
Close
()
cw
:=
ctx
util
.
NewWriter
(
ctx
,
s
)
// ok to use. we defer close stream in this func
cw
:=
ctx
io
.
NewWriter
(
ctx
,
s
)
// ok to use. we defer close stream in this func
w
:=
ggio
.
NewDelimitedWriter
(
cw
)
if
err
:=
w
.
WriteMsg
(
pmes
);
err
!=
nil
{
...
...
records.go
View file @
0e59a511
...
...
@@ -3,13 +3,13 @@ package dht
import
(
"fmt"
ctxfrac
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-context/frac"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
ci
"github.com/ipfs/go-ipfs/p2p/crypto"
peer
"github.com/ipfs/go-ipfs/p2p/peer"
routing
"github.com/ipfs/go-ipfs/routing"
pb
"github.com/ipfs/go-ipfs/routing/dht/pb"
record
"github.com/ipfs/go-ipfs/routing/record"
ctxutil
"github.com/ipfs/go-ipfs/util/ctx"
)
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
}
// ok, try the node itself. if they're overwhelmed or slow we can move on.
ctxT
,
cancelFunc
:=
ctx
util
.
WithDeadlineFraction
(
ctx
,
0.3
)
ctxT
,
cancelFunc
:=
ctx
frac
.
WithDeadlineFraction
(
ctx
,
0.3
)
defer
cancelFunc
()
if
pk
,
err
:=
dht
.
getPublicKeyFromNode
(
ctx
,
p
);
err
==
nil
{
err
:=
dht
.
peerstore
.
AddPubKey
(
p
,
pk
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment