mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 23:53:41 +02:00
htlcswitch+peer: CreateAndAddLink in switch, add messageSwitch to peer
This commit allows the peer to be tested without relying on a raw htlcswitch.Switch pointer. This is accomplished by using a messageSwitch interface and adding the CreateAndAddLink method to the htlcswitch.Switch.
This commit is contained in:
@@ -4,9 +4,36 @@ import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
// messageSwitch is an interface that abstracts managing the lifecycle of
|
||||
// abstract links. This is intended for peer package usage only.
|
||||
type messageSwitch interface {
|
||||
// BestHeight returns the best height known to the messageSwitch.
|
||||
BestHeight() uint32
|
||||
|
||||
// CircuitModifier returns a reference to the messageSwitch's internal
|
||||
// CircuitModifier which abstracts the paths payments take and allows
|
||||
// modifying them.
|
||||
CircuitModifier() htlcswitch.CircuitModifier
|
||||
|
||||
// RemoveLink removes an abstract link given a ChannelID.
|
||||
RemoveLink(cid lnwire.ChannelID)
|
||||
|
||||
// CreateAndAddLink creates an abstract link in the messageSwitch given
|
||||
// a ChannelLinkConfig and raw LightningChannel pointer.
|
||||
CreateAndAddLink(cfg htlcswitch.ChannelLinkConfig,
|
||||
lnChan *lnwallet.LightningChannel) error
|
||||
|
||||
// GetLinksByInterface retrieves abstract links (represented by the
|
||||
// ChannelUpdateHandler interface) based on the provided public key.
|
||||
GetLinksByInterface(pub [33]byte) ([]htlcswitch.ChannelUpdateHandler,
|
||||
error)
|
||||
}
|
||||
|
||||
// LinkUpdater is an interface implemented by most messages in BOLT 2 that are
|
||||
// allowed to update the channel state.
|
||||
type LinkUpdater interface {
|
||||
|
Reference in New Issue
Block a user