2016-09-10 03:13:50 +00:00
|
|
|
package floodsub
|
2016-09-10 00:15:39 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2016-09-10 15:28:29 +00:00
|
|
|
ma "github.com/jbenet/go-multiaddr"
|
|
|
|
inet "github.com/libp2p/go-libp2p/p2p/net"
|
2016-09-10 00:15:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ inet.Notifiee = (*PubSub)(nil)
|
|
|
|
|
|
|
|
func (p *PubSub) OpenedStream(n inet.Network, s inet.Stream) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PubSub) ClosedStream(n inet.Network, s inet.Stream) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PubSub) Connected(n inet.Network, c inet.Conn) {
|
|
|
|
s, err := p.host.NewStream(context.Background(), c.RemotePeer(), ID)
|
|
|
|
if err != nil {
|
|
|
|
log.Error("opening new stream to peer: ", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
p.newPeers <- s
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PubSub) Disconnected(n inet.Network, c inet.Conn) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PubSub) Listen(n inet.Network, _ ma.Multiaddr) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PubSub) ListenClose(n inet.Network, _ ma.Multiaddr) {
|
|
|
|
|
|
|
|
}
|