github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/connection/internal/relayNotifee.go (about) 1 package internal 2 3 import ( 4 "github.com/libp2p/go-libp2p/core/network" 5 "github.com/multiformats/go-multiaddr" 6 ) 7 8 // RelayNotifee is a notifiee that relays notifications to a list of notifiees. 9 // A network.Notifiee is a function that is called when a network event occurs, such as a new connection. 10 type RelayNotifee struct { 11 n []network.Notifiee 12 } 13 14 var _ network.Notifiee = (*RelayNotifee)(nil) 15 16 func NewRelayNotifee(notifiees ...network.Notifiee) *RelayNotifee { 17 return &RelayNotifee{notifiees} 18 } 19 20 func (r *RelayNotifee) Listen(n network.Network, multiaddr multiaddr.Multiaddr) { 21 for _, notifiee := range r.n { 22 notifiee.Listen(n, multiaddr) 23 } 24 } 25 26 func (r *RelayNotifee) ListenClose(n network.Network, multiaddr multiaddr.Multiaddr) { 27 for _, notifiee := range r.n { 28 notifiee.ListenClose(n, multiaddr) 29 } 30 } 31 32 func (r *RelayNotifee) Connected(n network.Network, conn network.Conn) { 33 for _, notifiee := range r.n { 34 notifiee.Connected(n, conn) 35 } 36 } 37 38 func (r *RelayNotifee) Disconnected(n network.Network, conn network.Conn) { 39 for _, notifiee := range r.n { 40 notifiee.Disconnected(n, conn) 41 } 42 }