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
badf9abf
Unverified
Commit
badf9abf
authored
Jul 02, 2020
by
Petar Radovic
Committed by
GitHub
Jul 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stream reset initial implementation (#407)
* stream reset
parent
9451b877
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
2 deletions
+20
-2
stream.go
pkg/p2p/libp2p/internal/handshake/mock/stream.go
+4
-0
libp2p.go
pkg/p2p/libp2p/libp2p.go
+2
-2
p2p.go
pkg/p2p/p2p.go
+1
-0
protobuf_test.go
pkg/p2p/protobuf/protobuf_test.go
+8
-0
streamtest.go
pkg/p2p/streamtest/streamtest.go
+5
-0
No files found.
pkg/p2p/libp2p/internal/handshake/mock/stream.go
View file @
badf9abf
...
@@ -63,3 +63,7 @@ func (s *Stream) Close() error {
...
@@ -63,3 +63,7 @@ func (s *Stream) Close() error {
func
(
s
*
Stream
)
FullClose
()
error
{
func
(
s
*
Stream
)
FullClose
()
error
{
return
nil
return
nil
}
}
func
(
s
*
Stream
)
Reset
()
error
{
return
nil
}
pkg/p2p/libp2p/libp2p.go
View file @
badf9abf
...
@@ -216,7 +216,7 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
...
@@ -216,7 +216,7 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
if
err
!=
nil
{
if
err
!=
nil
{
s
.
logger
.
Debugf
(
"handshake: handle %s: %v"
,
peerID
,
err
)
s
.
logger
.
Debugf
(
"handshake: handle %s: %v"
,
peerID
,
err
)
s
.
logger
.
Errorf
(
"unable to handshake with peer %v"
,
peerID
)
s
.
logger
.
Errorf
(
"unable to handshake with peer %v"
,
peerID
)
_
=
s
tream
.
Reset
()
_
=
handshakeS
tream
.
Reset
()
_
=
s
.
disconnect
(
peerID
)
_
=
s
.
disconnect
(
peerID
)
return
return
}
}
...
@@ -376,7 +376,7 @@ func (s *Service) Connect(ctx context.Context, addr ma.Multiaddr) (address *bzz.
...
@@ -376,7 +376,7 @@ func (s *Service) Connect(ctx context.Context, addr ma.Multiaddr) (address *bzz.
handshakeStream
:=
NewStream
(
stream
)
handshakeStream
:=
NewStream
(
stream
)
i
,
err
:=
s
.
handshakeService
.
Handshake
(
handshakeStream
,
stream
.
Conn
()
.
RemoteMultiaddr
(),
stream
.
Conn
()
.
RemotePeer
())
i
,
err
:=
s
.
handshakeService
.
Handshake
(
handshakeStream
,
stream
.
Conn
()
.
RemoteMultiaddr
(),
stream
.
Conn
()
.
RemotePeer
())
if
err
!=
nil
{
if
err
!=
nil
{
_
=
s
tream
.
Reset
()
_
=
handshakeS
tream
.
Reset
()
_
=
s
.
disconnect
(
info
.
ID
)
_
=
s
.
disconnect
(
info
.
ID
)
return
nil
,
fmt
.
Errorf
(
"handshake: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"handshake: %w"
,
err
)
}
}
...
...
pkg/p2p/p2p.go
View file @
badf9abf
...
@@ -35,6 +35,7 @@ type Stream interface {
...
@@ -35,6 +35,7 @@ type Stream interface {
io
.
Closer
io
.
Closer
Headers
()
Headers
Headers
()
Headers
FullClose
()
error
FullClose
()
error
Reset
()
error
}
}
// ProtocolSpec defines a collection of Stream specifications with handlers.
// ProtocolSpec defines a collection of Stream specifications with handlers.
...
...
pkg/p2p/protobuf/protobuf_test.go
View file @
badf9abf
...
@@ -387,6 +387,10 @@ func (noopWriteCloser) FullClose() error {
...
@@ -387,6 +387,10 @@ func (noopWriteCloser) FullClose() error {
return
nil
return
nil
}
}
func
(
noopWriteCloser
)
Reset
()
error
{
return
nil
}
type
noopReadCloser
struct
{
type
noopReadCloser
struct
{
io
.
Writer
io
.
Writer
}
}
...
@@ -410,3 +414,7 @@ func (noopReadCloser) Close() error {
...
@@ -410,3 +414,7 @@ func (noopReadCloser) Close() error {
func
(
noopReadCloser
)
FullClose
()
error
{
func
(
noopReadCloser
)
FullClose
()
error
{
return
nil
return
nil
}
}
func
(
noopReadCloser
)
Reset
()
error
{
return
nil
}
pkg/p2p/streamtest/streamtest.go
View file @
badf9abf
...
@@ -235,6 +235,11 @@ func (s *stream) FullClose() error {
...
@@ -235,6 +235,11 @@ func (s *stream) FullClose() error {
return
nil
return
nil
}
}
func
(
s
*
stream
)
Reset
()
error
{
//todo: :implement appropriately after all protocols are migrated and tested
return
s
.
Close
()
}
type
record
struct
{
type
record
struct
{
b
[]
byte
b
[]
byte
c
int
c
int
...
...
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