Commit b1e1d052 authored by Janos Guljas's avatar Janos Guljas

simplify p2p.Stream interface

parent 9e39d8cc
......@@ -162,6 +162,6 @@ type stream struct {
network.Stream
}
func (s stream) FullClose() error {
func (s stream) Close() error {
return helpers.FullClose(s)
}
......@@ -16,17 +16,7 @@ type Service interface {
type Stream interface {
io.ReadWriter
// Close closes the stream for writing. Reading will still work (that
// is, the remote side can still write).
io.Closer
// Reset closes both ends of the stream. Use this to tell the remote
// side to hang up and go away.
Reset() error
// Gracefully terminate stream on both ends.
FullClose() error
}
type Peer struct {
......
......@@ -45,7 +45,7 @@ func New(p2ps p2p.Service) (s *Service, err error) {
func (s *Service) Handler(p p2p.Peer) {
w, r := protobuf.NewRW(p.Stream)
defer p.Stream.FullClose()
defer p.Stream.Close()
var ping Ping
for {
......@@ -72,7 +72,7 @@ func (s *Service) Ping(ctx context.Context, peerID string, msgs ...string) (rtt
if err != nil {
return 0, fmt.Errorf("new stream: %w", err)
}
defer stream.FullClose()
defer stream.Close()
w, r := protobuf.NewRW(stream)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment