mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-11 22:24:14 +02:00
htlcswitch+peer: embed ChannelUpdateHandler in ChannelLink
GetLink, GetLinksByInterface now use ChannelUpdateHandler.
This commit is contained in:
@@ -57,6 +57,39 @@ type packetHandler interface {
|
||||
handleLocalAddPacket(*htlcPacket) error
|
||||
}
|
||||
|
||||
// ChannelUpdateHandler is an interface that provides methods that allow
|
||||
// sending lnwire.Message to the underlying link as well as querying state.
|
||||
type ChannelUpdateHandler interface {
|
||||
// HandleChannelUpdate handles the htlc requests as settle/add/fail
|
||||
// which sent to us from remote peer we have a channel with.
|
||||
//
|
||||
// NOTE: This function MUST be non-blocking (or block as little as
|
||||
// possible).
|
||||
HandleChannelUpdate(lnwire.Message)
|
||||
|
||||
// ChanID returns the channel ID for the channel link. The channel ID
|
||||
// is a more compact representation of a channel's full outpoint.
|
||||
ChanID() lnwire.ChannelID
|
||||
|
||||
// Bandwidth returns the amount of milli-satoshis which current link
|
||||
// might pass through channel link. The value returned from this method
|
||||
// represents the up to date available flow through the channel. This
|
||||
// takes into account any forwarded but un-cleared HTLC's, and any
|
||||
// HTLC's which have been set to the over flow queue.
|
||||
Bandwidth() lnwire.MilliSatoshi
|
||||
|
||||
// EligibleToForward returns a bool indicating if the channel is able
|
||||
// to actively accept requests to forward HTLC's. A channel may be
|
||||
// active, but not able to forward HTLC's if it hasn't yet finalized
|
||||
// the pre-channel operation protocol with the remote peer. The switch
|
||||
// will use this function in forwarding decisions accordingly.
|
||||
EligibleToForward() bool
|
||||
|
||||
// MayAddOutgoingHtlc returns an error if we may not add an outgoing
|
||||
// htlc to the channel.
|
||||
MayAddOutgoingHtlc() error
|
||||
}
|
||||
|
||||
// ChannelLink is an interface which represents the subsystem for managing the
|
||||
// incoming htlc requests, applying the changes to the channel, and also
|
||||
// propagating/forwarding it to htlc switch.
|
||||
@@ -81,20 +114,12 @@ type ChannelLink interface {
|
||||
// Embed the packetHandler interface.
|
||||
packetHandler
|
||||
|
||||
// HandleChannelUpdate handles the htlc requests as settle/add/fail
|
||||
// which sent to us from remote peer we have a channel with.
|
||||
//
|
||||
// NOTE: This function MUST be non-blocking (or block as little as
|
||||
// possible).
|
||||
HandleChannelUpdate(lnwire.Message)
|
||||
// Embed the ChannelUpdateHandler interface.
|
||||
ChannelUpdateHandler
|
||||
|
||||
// ChannelPoint returns the channel outpoint for the channel link.
|
||||
ChannelPoint() *wire.OutPoint
|
||||
|
||||
// ChanID returns the channel ID for the channel link. The channel ID
|
||||
// is a more compact representation of a channel's full outpoint.
|
||||
ChanID() lnwire.ChannelID
|
||||
|
||||
// ShortChanID returns the short channel ID for the channel link. The
|
||||
// short channel ID encodes the exact location in the main chain that
|
||||
// the original funding output can be found.
|
||||
@@ -129,13 +154,6 @@ type ChannelLink interface {
|
||||
CheckHtlcTransit(payHash [32]byte, amt lnwire.MilliSatoshi,
|
||||
timeout uint32, heightNow uint32) *LinkError
|
||||
|
||||
// Bandwidth returns the amount of milli-satoshis which current link
|
||||
// might pass through channel link. The value returned from this method
|
||||
// represents the up to date available flow through the channel. This
|
||||
// takes into account any forwarded but un-cleared HTLC's, and any
|
||||
// HTLC's which have been set to the over flow queue.
|
||||
Bandwidth() lnwire.MilliSatoshi
|
||||
|
||||
// Stats return the statistics of channel link. Number of updates,
|
||||
// total sent/received milli-satoshis.
|
||||
Stats() (uint64, lnwire.MilliSatoshi, lnwire.MilliSatoshi)
|
||||
@@ -144,17 +162,6 @@ type ChannelLink interface {
|
||||
// the channel link opened.
|
||||
Peer() lnpeer.Peer
|
||||
|
||||
// EligibleToForward returns a bool indicating if the channel is able
|
||||
// to actively accept requests to forward HTLC's. A channel may be
|
||||
// active, but not able to forward HTLC's if it hasn't yet finalized
|
||||
// the pre-channel operation protocol with the remote peer. The switch
|
||||
// will use this function in forwarding decisions accordingly.
|
||||
EligibleToForward() bool
|
||||
|
||||
// MayAddOutgoingHtlc returns an error if we may not add an outgoing
|
||||
// htlc to the channel.
|
||||
MayAddOutgoingHtlc() error
|
||||
|
||||
// AttachMailBox delivers an active MailBox to the link. The MailBox may
|
||||
// have buffered messages.
|
||||
AttachMailBox(MailBox)
|
||||
|
Reference in New Issue
Block a user