Skip to content

Commit d0ef248

Browse files
committed
htlcswitch: add HtlcView as PaymentBandwidth argument
In order to get more precise bandwidth reports, we also need to provide this method with the latest htlc view. Since aux data is committed to in the channel commitment, some uncommited HTLCs may not be accounted for, so we need to manually provide them via the HTLC view.
1 parent 53254c7 commit d0ef248

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

htlcswitch/interfaces.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/lightningnetwork/lnd/graph/db/models"
1111
"github.com/lightningnetwork/lnd/invoices"
1212
"github.com/lightningnetwork/lnd/lntypes"
13+
"github.com/lightningnetwork/lnd/lnwallet"
1314
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
1415
"github.com/lightningnetwork/lnd/lnwire"
1516
"github.com/lightningnetwork/lnd/record"
@@ -516,8 +517,8 @@ type AuxTrafficShaper interface {
516517
// is a custom channel that should be handled by the traffic shaper, the
517518
// ShouldHandleTraffic method should be called first.
518519
PaymentBandwidth(htlcBlob, commitmentBlob fn.Option[tlv.Blob],
519-
linkBandwidth,
520-
htlcAmt lnwire.MilliSatoshi) (lnwire.MilliSatoshi, error)
520+
linkBandwidth, htlcAmt lnwire.MilliSatoshi,
521+
htlcView lnwallet.AuxHtlcView) (lnwire.MilliSatoshi, error)
521522

522523
// IsCustomHTLC returns true if the HTLC carries the set of relevant
523524
// custom records to put it under the purview of the traffic shaper,

htlcswitch/link.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,6 +3505,7 @@ func (l *channelLink) AuxBandwidth(amount lnwire.MilliSatoshi,
35053505
commitmentBlob := l.CommitmentCustomBlob()
35063506
auxBandwidth, err := ts.PaymentBandwidth(
35073507
htlcBlob, commitmentBlob, l.Bandwidth(), amount,
3508+
l.channel.FetchLatestAuxHTLCView(),
35083509
)
35093510
if err != nil {
35103511
return fn.Err[OptionalBandwidth](fmt.Errorf("failed to get "+

routing/bandwidth_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/go-errors/errors"
88
"github.com/lightningnetwork/lnd/fn/v2"
99
"github.com/lightningnetwork/lnd/htlcswitch"
10+
"github.com/lightningnetwork/lnd/lnwallet"
1011
"github.com/lightningnetwork/lnd/lnwire"
1112
"github.com/lightningnetwork/lnd/tlv"
1213
"github.com/stretchr/testify/require"
@@ -150,7 +151,8 @@ func (*mockTrafficShaper) ShouldHandleTraffic(_ lnwire.ShortChannelID,
150151
// is a custom channel that should be handled by the traffic shaper, the
151152
// HandleTraffic method should be called first.
152153
func (*mockTrafficShaper) PaymentBandwidth(_, _ fn.Option[tlv.Blob],
153-
linkBandwidth, _ lnwire.MilliSatoshi) (lnwire.MilliSatoshi, error) {
154+
linkBandwidth, _ lnwire.MilliSatoshi,
155+
_ lnwallet.AuxHtlcView) (lnwire.MilliSatoshi, error) {
154156

155157
return linkBandwidth, nil
156158
}

0 commit comments

Comments
 (0)