github.com/mit-dci/lit@v0.0.0-20221102210550-8c3d3b49f2ce/lnp2p/events.go (about) 1 package lnp2p 2 3 import ( 4 "github.com/mit-dci/lit/crypto/koblitz" 5 "github.com/mit-dci/lit/eventbus" 6 "github.com/mit-dci/lit/lncore" 7 "github.com/mit-dci/lit/lndc" 8 ) 9 10 // NewPeerEvent is fired when a new peer is registered. 11 type NewPeerEvent struct { 12 Addr lncore.LnAddr 13 Peer *Peer 14 RemoteInitiated bool 15 16 // TODO REFACTORING: Remove these 17 RemotePub *koblitz.PublicKey 18 Conn *lndc.Conn 19 } 20 21 // Name . 22 func (e NewPeerEvent) Name() string { 23 return "lnp2p.peer.new" 24 } 25 26 // Flags . 27 func (e NewPeerEvent) Flags() uint8 { 28 return eventbus.EFLAG_UNCANCELLABLE 29 } 30 31 // PeerDisconnectEvent is fired when a peer is disconnected. 32 type PeerDisconnectEvent struct { 33 Peer *Peer 34 Reason string 35 } 36 37 // Name . 38 func (e PeerDisconnectEvent) Name() string { 39 return "lnp2p.peer.disconnect" 40 } 41 42 // Flags . 43 func (e PeerDisconnectEvent) Flags() uint8 { 44 return eventbus.EFLAG_UNCANCELLABLE 45 } 46 47 // NewListeningPortEvent . 48 type NewListeningPortEvent struct { 49 ListenPort int 50 } 51 52 // Name . 53 func (e NewListeningPortEvent) Name() string { 54 return "lnp2p.listen.start" 55 } 56 57 // Flags . 58 func (e NewListeningPortEvent) Flags() uint8 { 59 return eventbus.EFLAG_NORMAL 60 } 61 62 // StopListeningPortEvent . 63 type StopListeningPortEvent struct { 64 Port int 65 Reason string 66 } 67 68 // Name . 69 func (e StopListeningPortEvent) Name() string { 70 return "lnp2p.listen.stop" 71 } 72 73 // Flags . 74 func (e StopListeningPortEvent) Flags() uint8 { 75 return eventbus.EFLAG_ASYNC 76 }