htlcswitch: extend ChannelLink iface with dustHandler iface

This allows the Switch to determine the dust exposure of a certain
channel and allows the link to set the feerate of the mailbox given
a fee update.
This commit is contained in:
eugene committed 2021-09-30 13:44:34 -04:00
1 parent 0b24603aef
commit 0ce6194e1e
3 files changed
+80

No files matched your search

+19
View File
@@ -7,6 +7,7 @@ import (
"github.com/lightningnetwork/lnd/lnpeer"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/record"
)
@@ -57,6 +58,21 @@ type packetHandler interface {
handleLocalAddPacket(*htlcPacket) error
}
// dustHandler is an interface used exclusively by the Switch to evaluate
// whether a link has too much dust exposure.
type dustHandler interface {
// getDustSum returns the dust sum on either the local or remote
// commitment.
getDustSum(remote bool) lnwire.MilliSatoshi
// getFeeRate returns the current channel feerate.
getFeeRate() chainfee.SatPerKWeight
// getDustClosure returns a closure that can evaluate whether a passed
// HTLC is dust.
getDustClosure() dustClosure
}
// ChannelUpdateHandler is an interface that provides methods that allow
// sending lnwire.Message to the underlying link as well as querying state.
type ChannelUpdateHandler interface {
@@ -122,6 +138,9 @@ type ChannelLink interface {
// Embed the ChannelUpdateHandler interface.
ChannelUpdateHandler
// Embed the dustHandler interface.
dustHandler
// ChannelPoint returns the channel outpoint for the channel link.
ChannelPoint() *wire.OutPoint