2018-06-08 06:05:32 +03:00
|
|
|
package lnpeer
|
|
|
|
|
|
|
|
import (
|
2018-07-05 23:26:55 +03:00
|
|
|
"net"
|
|
|
|
|
2018-06-05 04:41:41 +03:00
|
|
|
"github.com/btcsuite/btcd/btcec"
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
2018-09-26 12:12:57 +03:00
|
|
|
"github.com/lightningnetwork/lnd/channeldb"
|
2018-06-08 06:05:32 +03:00
|
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Peer is an interface which represents the remote lightning node inside our
|
|
|
|
// system.
|
|
|
|
type Peer interface {
|
2019-03-06 04:08:22 +03:00
|
|
|
// SendMessage sends a variadic number of high-priority message to
|
|
|
|
// remote peer. The first argument denotes if the method should block
|
|
|
|
// until the messages have been sent to the remote peer or an error is
|
|
|
|
// returned, otherwise it returns immediately after queuing.
|
|
|
|
SendMessage(sync bool, msgs ...lnwire.Message) error
|
|
|
|
|
|
|
|
// SendMessageLazy sends a variadic number of low-priority message to
|
|
|
|
// remote peer. The first argument denotes if the method should block
|
|
|
|
// until the messages have been sent to the remote peer or an error is
|
|
|
|
// returned, otherwise it returns immediately after queueing.
|
|
|
|
SendMessageLazy(sync bool, msgs ...lnwire.Message) error
|
2018-06-08 06:05:32 +03:00
|
|
|
|
2018-07-05 23:26:55 +03:00
|
|
|
// AddNewChannel adds a new channel to the peer. The channel should fail
|
|
|
|
// to be added if the cancel channel is closed.
|
2018-09-26 12:12:57 +03:00
|
|
|
AddNewChannel(channel *channeldb.OpenChannel, cancel <-chan struct{}) error
|
2018-07-05 23:26:55 +03:00
|
|
|
|
2018-06-08 06:05:32 +03:00
|
|
|
// WipeChannel removes the channel uniquely identified by its channel
|
|
|
|
// point from all indexes associated with the peer.
|
|
|
|
WipeChannel(*wire.OutPoint) error
|
|
|
|
|
|
|
|
// PubKey returns the serialized public key of the remote peer.
|
|
|
|
PubKey() [33]byte
|
|
|
|
|
|
|
|
// IdentityKey returns the public key of the remote peer.
|
|
|
|
IdentityKey() *btcec.PublicKey
|
2018-07-05 23:26:55 +03:00
|
|
|
|
|
|
|
// Address returns the network address of the remote peer.
|
|
|
|
Address() net.Addr
|
2018-08-26 03:10:25 +03:00
|
|
|
|
|
|
|
// QuitSignal is a method that should return a channel which will be
|
|
|
|
// sent upon or closed once the backing peer exits. This allows callers
|
|
|
|
// using the interface to cancel any processing in the event the backing
|
|
|
|
// implementation exits.
|
|
|
|
QuitSignal() <-chan struct{}
|
2019-09-11 15:41:08 +03:00
|
|
|
|
|
|
|
// LocalGlobalFeatures returns the set of global features that has been
|
|
|
|
// advertised by the local peer. This allows sub-systems that use this
|
|
|
|
// interface to gate their behavior off the set of negotiated feature
|
|
|
|
// bits.
|
|
|
|
LocalGlobalFeatures() *lnwire.FeatureVector
|
|
|
|
|
|
|
|
// RemoteGlobalFeatures returns the set of global features that has
|
|
|
|
// been advertised by the remote peer. This allows sub-systems that use
|
|
|
|
// this interface to gate their behavior off the set of negotiated
|
|
|
|
// feature bits.
|
|
|
|
RemoteGlobalFeatures() *lnwire.FeatureVector
|
2018-06-08 06:05:32 +03:00
|
|
|
}
|