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
9bf7e6dd
Commit
9bf7e6dd
authored
Feb 10, 2020
by
Petar Radovic
Committed by
GitHub
Feb 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wait for remote stream to close in handshake (#13)
parent
b46a390c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
libp2p.go
pkg/p2p/libp2p/libp2p.go
+9
-3
No files found.
pkg/p2p/libp2p/libp2p.go
View file @
9bf7e6dd
...
...
@@ -11,6 +11,8 @@ import (
"fmt"
"net"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
handshake
"github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake"
...
...
@@ -262,9 +264,8 @@ func (s *Service) Connect(ctx context.Context, addr ma.Multiaddr) (overlay swarm
stream
,
err
:=
s
.
newStreamForPeerID
(
ctx
,
info
.
ID
,
handshake
.
ProtocolName
,
handshake
.
ProtocolVersion
,
handshake
.
StreamName
)
if
err
!=
nil
{
_
=
s
.
host
.
Network
()
.
ClosePeer
(
info
.
ID
)
return
swarm
.
Address
{},
fmt
.
Errorf
(
"new stream: %w"
,
err
)
return
swarm
.
Address
{},
err
}
defer
stream
.
Close
()
i
,
err
:=
s
.
handshakeService
.
Handshake
(
stream
)
if
err
!=
nil
{
...
...
@@ -272,6 +273,11 @@ func (s *Service) Connect(ctx context.Context, addr ma.Multiaddr) (overlay swarm
return
swarm
.
Address
{},
err
}
if
err
:=
helpers
.
FullClose
(
stream
);
err
!=
nil
{
_
=
stream
.
Reset
()
return
swarm
.
Address
{},
err
}
s
.
peers
.
add
(
info
.
ID
,
i
.
Address
)
s
.
metrics
.
CreatedConnectionCount
.
Inc
()
s
.
logger
.
Infof
(
"peer %s connected"
,
i
.
Address
)
...
...
@@ -299,7 +305,7 @@ func (s *Service) NewStream(ctx context.Context, overlay swarm.Address, protocol
return
s
.
newStreamForPeerID
(
ctx
,
peerID
,
protocolName
,
protocolVersion
,
streamName
)
}
func
(
s
*
Service
)
newStreamForPeerID
(
ctx
context
.
Context
,
peerID
libp2ppeer
.
ID
,
protocolName
,
protocolVersion
,
streamName
string
)
(
p2p
.
Stream
,
error
)
{
func
(
s
*
Service
)
newStreamForPeerID
(
ctx
context
.
Context
,
peerID
libp2ppeer
.
ID
,
protocolName
,
protocolVersion
,
streamName
string
)
(
network
.
Stream
,
error
)
{
swarmStreamName
:=
p2p
.
NewSwarmStreamName
(
protocolName
,
protocolVersion
,
streamName
)
st
,
err
:=
s
.
host
.
NewStream
(
ctx
,
peerID
,
protocol
.
ID
(
swarmStreamName
))
if
err
!=
nil
{
...
...
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