Browse Source

parallel identify push

pull/454/head
vyzo 6 years ago
parent
commit
7fabe39290
  1. 6
      p2p/protocol/identify/id.go

6
p2p/protocol/identify/id.go

@ -149,15 +149,17 @@ func (ids *IDService) pushHandler(s inet.Stream) {
func (ids *IDService) Push() { func (ids *IDService) Push() {
for _, p := range ids.Host.Network().Peers() { for _, p := range ids.Host.Network().Peers() {
go func(p peer.ID) {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
s, err := ids.Host.NewStream(ctx, p, IDPush) s, err := ids.Host.NewStream(ctx, p, IDPush)
cancel()
if err != nil { if err != nil {
log.Debugf("error opening push stream: %s", err.Error()) log.Debugf("error opening push stream: %s", err.Error())
continue return
} }
ids.requestHandler(s) ids.requestHandler(s)
}(p)
} }
} }

Loading…
Cancel
Save