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
f0593aa9
Commit
f0593aa9
authored
Jun 17, 2019
by
Cole Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace delimited reader in message sender
parent
feee52a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
dht_net.go
dht_net.go
+9
-4
No files found.
dht_net.go
View file @
f0593aa9
...
...
@@ -259,7 +259,7 @@ func (dht *IpfsDHT) messageSenderForPeer(ctx context.Context, p peer.ID) (*messa
type
messageSender
struct
{
s
network
.
Stream
r
g
gio
.
ReadCloser
r
ms
gio
.
ReadCloser
lk
sync
.
Mutex
p
peer
.
ID
dht
*
IpfsDHT
...
...
@@ -302,7 +302,7 @@ func (ms *messageSender) prep(ctx context.Context) error {
return
err
}
ms
.
r
=
g
gio
.
New
Delimited
Reader
(
nstr
,
network
.
MessageSizeMax
)
ms
.
r
=
ms
gio
.
New
Varint
Reader
(
nstr
)
ms
.
s
=
nstr
return
nil
...
...
@@ -403,8 +403,13 @@ func (ms *messageSender) writeMsg(pmes *pb.Message) error {
func
(
ms
*
messageSender
)
ctxReadMsg
(
ctx
context
.
Context
,
mes
*
pb
.
Message
)
error
{
errc
:=
make
(
chan
error
,
1
)
go
func
(
r
ggio
.
ReadCloser
)
{
errc
<-
r
.
ReadMsg
(
mes
)
go
func
(
r
msgio
.
ReadCloser
)
{
bytes
,
err
:=
r
.
ReadMsg
()
if
err
!=
nil
{
errc
<-
err
return
}
errc
<-
mes
.
Unmarshal
(
bytes
)
}(
ms
.
r
)
t
:=
time
.
NewTimer
(
dhtReadMessageTimeout
)
...
...
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