Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
b1e1d052
Commit
b1e1d052
authored
Jan 17, 2020
by
Janos Guljas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify p2p.Stream interface
parent
9e39d8cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
13 deletions
+3
-13
libp2p.go
pkg/p2p/libp2p/libp2p.go
+1
-1
p2p.go
pkg/p2p/p2p.go
+0
-10
pingpong.go
pkg/pingpong/pingpong.go
+2
-2
No files found.
pkg/p2p/libp2p/libp2p.go
View file @
b1e1d052
...
...
@@ -162,6 +162,6 @@ type stream struct {
network
.
Stream
}
func
(
s
stream
)
Full
Close
()
error
{
func
(
s
stream
)
Close
()
error
{
return
helpers
.
FullClose
(
s
)
}
pkg/p2p/p2p.go
View file @
b1e1d052
...
...
@@ -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
{
...
...
pkg/pingpong/pingpong.go
View file @
b1e1d052
...
...
@@ -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
.
Full
Close
()
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
.
Full
Close
()
defer
stream
.
Close
()
w
,
r
:=
protobuf
.
NewRW
(
stream
)
...
...
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