go-libp2p-pubsub/notify.go
keks 7dd4e0bfeb vet
used for range variable inside goroutine, now passed as argument
2018-01-13 12:12:21 +02:00

42 lines
927 B
Go

package floodsub
import (
inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net"
ma "gx/ipfs/QmXY77cVe7rVRQXZZQRioukUM7aRW3BTcAgJe12MCtb3Ji/go-multiaddr"
)
var _ inet.Notifiee = (*PubSubNotif)(nil)
type PubSubNotif PubSub
func (p *PubSubNotif) OpenedStream(n inet.Network, s inet.Stream) {
}
func (p *PubSubNotif) ClosedStream(n inet.Network, s inet.Stream) {
}
func (p *PubSubNotif) Connected(n inet.Network, c inet.Conn) {
go func() {
s, err := p.host.NewStream(p.ctx, c.RemotePeer(), ID)
if err != nil {
log.Warning("opening new stream to peer: ", err, c.LocalPeer(), c.RemotePeer())
return
}
select {
case p.newPeers <- s:
case <-p.ctx.Done():
s.Reset()
}
}()
}
func (p *PubSubNotif) Disconnected(n inet.Network, c inet.Conn) {
}
func (p *PubSubNotif) Listen(n inet.Network, _ ma.Multiaddr) {
}
func (p *PubSubNotif) ListenClose(n inet.Network, _ ma.Multiaddr) {
}