Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
3b2f4641
Commit
3b2f4641
authored
7 years ago
by
vyzo
Browse files
Options
Download
Email Patches
Plain Diff
RoutedHost: use Connect directly in NewStream
parent
daaf97b4
master
2018-Q4-OKR
feat/protobuf
feat/udp
fix/473
fix/no-custom-field
fix/reset-ping-stream
fix/revert-correct-external-addr
gx/update-jccl6u
gx/update-nza0mn
jenkinsfile
kevina/fix-go-vet
multistream-ping
punching
revert-276-update-go-detect-race
v6.0.23
v6.0.22
v6.0.21
v6.0.20
v6.0.19
v6.0.18
v6.0.17
v6.0.16
v6.0.15
v6.0.14
v6.0.13
v6.0.12
v6.0.11
v6.0.10
v6.0.9
v6.0.8
v6.0.7
v6.0.6
v6.0.5
v6.0.4
v6.0.3
v6.0.2
v6.0.1
v6.0.0
v5.0.21
v5.0.20
v5.0.19
v5.0.18
v5.0.17
v5.0.16
v5.0.15
v5.0.14
v5.0.13
v5.0.12
v5.0.11
v5.0.10
v5.0.9
v5.0.8
v5.0.7
v5.0.6
v5.0.5
v5.0.4
v5.0.3
v5.0.2
v5.0.1
v5.0.0
v4.5.5
v4.5.4
v4.5.3
v4.5.2
v4.5.1
v4.5.0
v4.4.5
v4.4.4
v4.4.3
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
p2p/host/routed/routed.go
+6
-7
p2p/host/routed/routed.go
with
6 additions
and
7 deletions
+6
-7
p2p/host/routed/routed.go
View file @
3b2f4641
...
...
@@ -128,13 +128,12 @@ func (rh *RoutedHost) RemoveStreamHandler(pid protocol.ID) {
}
func
(
rh
*
RoutedHost
)
NewStream
(
ctx
context
.
Context
,
p
peer
.
ID
,
pids
...
protocol
.
ID
)
(
inet
.
Stream
,
error
)
{
// check if we need to find some addresses for the peer through the routing system
if
len
(
rh
.
Network
()
.
ConnsToPeer
(
p
))
==
0
&&
len
(
rh
.
Peerstore
()
.
Addrs
(
p
))
==
0
{
addrs
,
err
:=
rh
.
findPeerAddrs
(
ctx
,
p
)
if
err
!=
nil
{
return
nil
,
err
}
rh
.
Peerstore
()
.
AddAddrs
(
p
,
addrs
,
pstore
.
TempAddrTTL
)
// Ensure we have a connection, with peer addresses resolved by the routing system (#207)
// It is not sufficient to let the underlying host connect, it will most likely not have
// any addresses for the peer without any prior connections.
err
:=
rh
.
Connect
(
ctx
,
pstore
.
PeerInfo
{
ID
:
p
})
if
err
!=
nil
{
return
nil
,
err
}
return
rh
.
host
.
NewStream
(
ctx
,
p
,
pids
...
)
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help