Skip to content

Commit 4ad8462

Browse files
committed
htlcswitch+routing: PaymentBandwidth accepts channel peer pubkey argument
1 parent 1793b1a commit 4ad8462

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

htlcswitch/interfaces.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ type AuxTrafficShaper interface {
522522
PaymentBandwidth(fundingBlob, htlcBlob,
523523
commitmentBlob fn.Option[tlv.Blob],
524524
linkBandwidth, htlcAmt lnwire.MilliSatoshi,
525-
htlcView lnwallet.AuxHtlcView) (lnwire.MilliSatoshi, error)
525+
htlcView lnwallet.AuxHtlcView,
526+
peer route.Vertex) (lnwire.MilliSatoshi, error)
526527

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

htlcswitch/link.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/lightningnetwork/lnd/lnwire"
3232
"github.com/lightningnetwork/lnd/queue"
3333
"github.com/lightningnetwork/lnd/record"
34+
"github.com/lightningnetwork/lnd/routing/route"
3435
"github.com/lightningnetwork/lnd/ticker"
3536
"github.com/lightningnetwork/lnd/tlv"
3637
)
@@ -3503,11 +3504,19 @@ func (l *channelLink) AuxBandwidth(amount lnwire.MilliSatoshi,
35033504
})
35043505
}
35053506

3507+
peerBytes := l.cfg.Peer.PubKey()
3508+
3509+
peer, err := route.NewVertexFromBytes(peerBytes[:])
3510+
if err != nil {
3511+
return fn.Err[OptionalBandwidth](fmt.Errorf("failed to decode "+
3512+
"peer pub key: %v", err))
3513+
}
3514+
35063515
// Ask for a specific bandwidth to be used for the channel.
35073516
commitmentBlob := l.CommitmentCustomBlob()
35083517
auxBandwidth, err := ts.PaymentBandwidth(
35093518
fundingBlob, htlcBlob, commitmentBlob, l.Bandwidth(), amount,
3510-
l.channel.FetchLatestAuxHTLCView(),
3519+
l.channel.FetchLatestAuxHTLCView(), peer,
35113520
)
35123521
if err != nil {
35133522
return fn.Err[OptionalBandwidth](fmt.Errorf("failed to get "+

routing/bandwidth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (*mockTrafficShaper) ShouldHandleTraffic(_ lnwire.ShortChannelID,
153153
// ShouldHandleTraffic method should be called first.
154154
func (*mockTrafficShaper) PaymentBandwidth(_, _, _ fn.Option[tlv.Blob],
155155
linkBandwidth, _ lnwire.MilliSatoshi,
156-
_ lnwallet.AuxHtlcView) (lnwire.MilliSatoshi, error) {
156+
_ lnwallet.AuxHtlcView, _ route.Vertex) (lnwire.MilliSatoshi, error) {
157157

158158
return linkBandwidth, nil
159159
}

0 commit comments

Comments
 (0)