Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Revert "buffer writes"
Browse files Browse the repository at this point in the history
This reverts commit fc1278e.

It appears that using a buffer here is no longer necessary after the
upstream fix gogo/protobuf#504
  • Loading branch information
bpot committed Mar 27, 2019
1 parent 98550f7 commit c9aa374
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions network/ipfs_impl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package network

import (
"bufio"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -74,32 +73,26 @@ 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
}
default:
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)
}
Expand Down

0 comments on commit c9aa374

Please sign in to comment.