Commit aa4f9dac authored by Adin Schmahmann's avatar Adin Schmahmann Committed by vyzo

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

fix: treat peers already connected to the host before pubsub is initialized as valid potential pubsub peers
parent 4336d5ae
...@@ -32,3 +32,12 @@ func (p *PubSubNotif) Listen(n network.Network, _ ma.Multiaddr) { ...@@ -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) 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():
}
}
}
...@@ -292,6 +292,8 @@ func NewPubSub(ctx context.Context, h host.Host, rt PubSubRouter, opts ...Option ...@@ -292,6 +292,8 @@ func NewPubSub(ctx context.Context, h host.Host, rt PubSubRouter, opts ...Option
go ps.processLoop(ctx) go ps.processLoop(ctx)
(*PubSubNotif)(ps).Initialize()
return ps, nil return ps, nil
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment