fix: treat peers already connected to the host before pubsub is initialized as valid potential pubsub peers

This commit is contained in:
Adin Schmahmann 2020-12-06 14:53:25 -05:00 committed by vyzo
parent 4336d5ae71
commit aa4f9dac2f
2 changed files with 11 additions and 0 deletions

View File

@ -32,3 +32,12 @@ func (p *PubSubNotif) Listen(n network.Network, _ ma.Multiaddr) {
func (p *PubSubNotif) ListenClose(n network.Network, _ ma.Multiaddr) {
}
func (p *PubSubNotif) Initialize() {
for _, pr := range p.host.Network().Peers() {
select {
case p.newPeers <- pr:
case <-p.ctx.Done():
}
}
}

View File

@ -292,6 +292,8 @@ func NewPubSub(ctx context.Context, h host.Host, rt PubSubRouter, opts ...Option
go ps.processLoop(ctx)
(*PubSubNotif)(ps).Initialize()
return ps, nil
}