Skip to content
GitLab
Menu
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
7fabe392
Commit
7fabe392
authored
Oct 18, 2018
by
vyzo
Browse files
parallel identify push
parent
477c19aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/protocol/identify/id.go
View file @
7fabe392
...
...
@@ -149,15 +149,17 @@ func (ids *IDService) pushHandler(s inet.Stream) {
func
(
ids
*
IDService
)
Push
()
{
for
_
,
p
:=
range
ids
.
Host
.
Network
()
.
Peers
()
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
60
*
time
.
Second
)
s
,
err
:=
ids
.
Host
.
NewStream
(
ctx
,
p
,
IDPush
)
cancel
()
if
err
!=
nil
{
log
.
Debugf
(
"error opening push stream: %s"
,
err
.
Error
())
continue
}
go
func
(
p
peer
.
ID
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
60
*
time
.
Second
)
defer
cancel
()
s
,
err
:=
ids
.
Host
.
NewStream
(
ctx
,
p
,
IDPush
)
if
err
!=
nil
{
log
.
Debugf
(
"error opening push stream: %s"
,
err
.
Error
())
return
}
ids
.
requestHandler
(
s
)
ids
.
requestHandler
(
s
)
}(
p
)
}
}
...
...
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