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
088fd5f7
Unverified
Commit
088fd5f7
authored
Mar 28, 2019
by
Steven Allen
Committed by
GitHub
Mar 28, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #103 from bpot/bp-revert-buffered-write
Reduce memory allocation
parents
98550f76
c9aa3744
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
10 deletions
+3
-10
network/ipfs_impl.go
network/ipfs_impl.go
+3
-10
No files found.
network/ipfs_impl.go
View file @
088fd5f7
package
network
import
(
"bufio"
"context"
"fmt"
"io"
...
...
@@ -74,20 +73,19 @@ 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
(
w
);
err
!=
nil
{
if
err
:=
msg
.
ToNetV1
(
s
);
err
!=
nil
{
log
.
Debugf
(
"error: %s"
,
err
)
return
err
}
case
ProtocolBitswapOne
,
ProtocolBitswapNoVers
:
if
err
:=
msg
.
ToNetV0
(
w
);
err
!=
nil
{
if
err
:=
msg
.
ToNetV0
(
s
);
err
!=
nil
{
log
.
Debugf
(
"error: %s"
,
err
)
return
err
}
...
...
@@ -95,11 +93,6 @@ 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