-
Notifications
You must be signed in to change notification settings - Fork 42
/
notify.go
41 lines (31 loc) · 1.01 KB
/
notify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package floodsub
import (
ma "github.com/ipfs/fs-repo-migrations/ipfs-6-to-7/gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr"
inet "github.com/ipfs/fs-repo-migrations/ipfs-6-to-7/gx/ipfs/QmXfkENeeBvh3zYA51MaSdGUdBjhQ99cP5WQe8zgr6wchG/go-libp2p-net"
)
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(), p.rt.Protocols()...)
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) {
}