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
dms3
go-bitswap
Commits
fc1278e6
Commit
fc1278e6
authored
Oct 17, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer writes
Let's not split every wantlist into a length and a wantlist...
parent
e12de92f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
network/ipfs_impl.go
network/ipfs_impl.go
+10
-3
No files found.
network/ipfs_impl.go
View file @
fc1278e6
package
network
import
(
"bufio"
"context"
"fmt"
"io"
...
...
@@ -70,19 +71,20 @@ func msgToStream(ctx context.Context, s inet.Stream, msg bsmsg.BitSwapMessage) e
if
dl
,
ok
:=
ctx
.
Deadline
();
ok
{
deadline
=
dl
}
if
err
:=
s
.
SetWriteDeadline
(
deadline
);
err
!=
nil
{
log
.
Warningf
(
"error setting deadline: %s"
,
err
)
}
w
:=
bufio
.
NewWriter
(
s
)
switch
s
.
Protocol
()
{
case
ProtocolBitswap
:
if
err
:=
msg
.
ToNetV1
(
s
);
err
!=
nil
{
if
err
:=
msg
.
ToNetV1
(
w
);
err
!=
nil
{
log
.
Debugf
(
"error: %s"
,
err
)
return
err
}
case
ProtocolBitswapOne
,
ProtocolBitswapNoVers
:
if
err
:=
msg
.
ToNetV0
(
s
);
err
!=
nil
{
if
err
:=
msg
.
ToNetV0
(
w
);
err
!=
nil
{
log
.
Debugf
(
"error: %s"
,
err
)
return
err
}
...
...
@@ -90,6 +92,11 @@ func msgToStream(ctx context.Context, s inet.Stream, msg bsmsg.BitSwapMessage) e
return
fmt
.
Errorf
(
"unrecognized protocol on remote: %s"
,
s
.
Protocol
())
}
if
err
:=
w
.
Flush
();
err
!=
nil
{
log
.
Debugf
(
"error: %s"
,
err
)
return
err
}
if
err
:=
s
.
SetWriteDeadline
(
time
.
Time
{});
err
!=
nil
{
log
.
Warningf
(
"error resetting deadline: %s"
,
err
)
}
...
...
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