github.com/decred/dcrlnd@v0.7.6/lnpeer/peer.go (about) 1 package lnpeer 2 3 import ( 4 "net" 5 6 "github.com/decred/dcrd/dcrec/secp256k1/v4" 7 "github.com/decred/dcrd/wire" 8 "github.com/decred/dcrlnd/channeldb" 9 "github.com/decred/dcrlnd/lnwire" 10 ) 11 12 // Peer is an interface which represents a remote lightning node. 13 type Peer interface { 14 // SendMessage sends a variadic number of high-priority message to 15 // remote peer. The first argument denotes if the method should block 16 // until the messages have been sent to the remote peer or an error is 17 // returned, otherwise it returns immediately after queuing. 18 SendMessage(sync bool, msgs ...lnwire.Message) error 19 20 // SendMessageLazy sends a variadic number of low-priority message to 21 // remote peer. The first argument denotes if the method should block 22 // until the messages have been sent to the remote peer or an error is 23 // returned, otherwise it returns immediately after queueing. 24 SendMessageLazy(sync bool, msgs ...lnwire.Message) error 25 26 // AddNewChannel adds a new channel to the peer. The channel should fail 27 // to be added if the cancel channel is closed. 28 AddNewChannel(channel *channeldb.OpenChannel, cancel <-chan struct{}) error 29 30 // WipeChannel removes the channel uniquely identified by its channel 31 // point from all indexes associated with the peer. 32 WipeChannel(*wire.OutPoint) 33 34 // PubKey returns the serialized public key of the remote peer. 35 PubKey() [33]byte 36 37 // IdentityKey returns the public key of the remote peer. 38 IdentityKey() *secp256k1.PublicKey 39 40 // Address returns the network address of the remote peer. 41 Address() net.Addr 42 43 // Inbound returns whether the remote peer connected to one of our 44 // listening endpoints or if we initiated the connection. 45 Inbound() bool 46 47 // QuitSignal is a method that should return a channel which will be 48 // sent upon or closed once the backing peer exits. This allows callers 49 // using the interface to cancel any processing in the event the backing 50 // implementation exits. 51 QuitSignal() <-chan struct{} 52 53 // LocalFeatures returns the set of features that has been advertised by 54 // the us to the remote peer. This allows sub-systems that use this 55 // interface to gate their behavior off the set of negotiated feature 56 // bits. 57 LocalFeatures() *lnwire.FeatureVector 58 59 // RemoteFeatures returns the set of features that has been advertised 60 // by the remote peer. This allows sub-systems that use this interface 61 // to gate their behavior off the set of negotiated feature bits. 62 RemoteFeatures() *lnwire.FeatureVector 63 }