lnd.xprv/lnpeer/peer.go
Olaoluwa Osuntokun 1364dca5a6
lnpeer: extend Peer interface with new QuitSignal method
In this commit, we extend the Peer interface with a new QuitSignal
method. This method is meant to expose a read-only quit channel which
will allow callers to cancel any actions based on the lifetime of the
underlying peer.
2018-08-25 17:30:13 -07:00

43 lines
1.4 KiB
Go

package lnpeer
import (
"net"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
)
// Peer is an interface which represents the remote lightning node inside our
// system.
type Peer interface {
// SendMessage sends a variadic number of message to remote peer. The
// first argument denotes if the method should block until the message
// has been sent to the remote peer.
SendMessage(sync bool, msg ...lnwire.Message) error
// AddNewChannel adds a new channel to the peer. The channel should fail
// to be added if the cancel channel is closed.
AddNewChannel(channel *lnwallet.LightningChannel, cancel <-chan struct{}) error
// 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
// Address returns the network address of the remote peer.
Address() net.Addr
// 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{}
}