Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
584cdd39
Commit
584cdd39
authored
Feb 14, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make NewStream run FindPeer if no addresses found
parent
6241c259
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
p2p/host/routed/routed.go
p2p/host/routed/routed.go
+8
-0
No files found.
p2p/host/routed/routed.go
View file @
584cdd39
...
...
@@ -100,6 +100,14 @@ func (rh *RoutedHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandl
rh
.
host
.
SetStreamHandler
(
pid
,
handler
)
}
func
(
rh
*
RoutedHost
)
NewStream
(
pid
protocol
.
ID
,
p
peer
.
ID
)
(
inet
.
Stream
,
error
)
{
if
len
(
rh
.
Peerstore
()
.
Addrs
(
p
))
<
1
{
ctx
,
_
:=
context
.
WithTimeout
(
context
.
TODO
(),
time
.
Second
*
30
)
pi
,
err
:=
rh
.
route
.
FindPeer
(
ctx
,
p
)
if
err
!=
nil
{
return
nil
,
err
}
rh
.
Peerstore
()
.
AddAddrs
(
p
,
pi
.
Addrs
,
peer
.
TempAddrTTL
)
}
return
rh
.
host
.
NewStream
(
pid
,
p
)
}
func
(
rh
*
RoutedHost
)
Close
()
error
{
...
...
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