Skip to content

Commit c25f98f

Browse files
authored
Merge pull request lightningnetwork#9727 from guggero/strict-forwarding
Aux bandwidth manager: also pass HTLC blob to `ShouldHandleTraffic`
2 parents a304be6 + 5fb0f43 commit c25f98f

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

htlcswitch/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ type AuxTrafficShaper interface {
509509
// identified by the provided channel ID may have external mechanisms
510510
// that would allow it to carry out the payment.
511511
ShouldHandleTraffic(cid lnwire.ShortChannelID,
512-
fundingBlob fn.Option[tlv.Blob]) (bool, error)
512+
fundingBlob, htlcBlob fn.Option[tlv.Blob]) (bool, error)
513513

514514
// PaymentBandwidth returns the available bandwidth for a custom channel
515515
// decided by the given channel aux blob and HTLC blob. A return value

htlcswitch/link.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3484,7 +3484,7 @@ func (l *channelLink) AuxBandwidth(amount lnwire.MilliSatoshi,
34843484
ts AuxTrafficShaper) fn.Result[OptionalBandwidth] {
34853485

34863486
fundingBlob := l.FundingCustomBlob()
3487-
shouldHandle, err := ts.ShouldHandleTraffic(cid, fundingBlob)
3487+
shouldHandle, err := ts.ShouldHandleTraffic(cid, fundingBlob, htlcBlob)
34883488
if err != nil {
34893489
return fn.Err[OptionalBandwidth](fmt.Errorf("traffic shaper "+
34903490
"failed to decide whether to handle traffic: %w", err))

htlcswitch/switch.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,9 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
11491149
func (s *Switch) checkCircularForward(incoming, outgoing lnwire.ShortChannelID,
11501150
allowCircular bool, paymentHash lntypes.Hash) *LinkError {
11511151

1152+
log.Tracef("Checking for circular route: incoming=%v, outgoing=%v "+
1153+
"(payment hash: %x)", incoming, outgoing, paymentHash[:])
1154+
11521155
// If they are equal, we can skip the alias mapping checks.
11531156
if incoming == outgoing {
11541157
// The switch may be configured to allow circular routes, so
@@ -1189,6 +1192,10 @@ func (s *Switch) checkCircularForward(incoming, outgoing lnwire.ShortChannelID,
11891192

11901193
// Check base SCID equality.
11911194
if incomingBaseScid != outgoingBaseScid {
1195+
log.Tracef("Incoming base SCID %v does not match outgoing "+
1196+
"base SCID %v (payment hash: %x)", incomingBaseScid,
1197+
outgoingBaseScid, paymentHash[:])
1198+
11921199
// The base SCIDs are not equal so these are not the same
11931200
// channel.
11941201
return nil

routing/bandwidth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ type mockTrafficShaper struct{}
140140
// by the provided channel ID may have external mechanisms that would
141141
// allow it to carry out the payment.
142142
func (*mockTrafficShaper) ShouldHandleTraffic(_ lnwire.ShortChannelID,
143-
_ fn.Option[tlv.Blob]) (bool, error) {
143+
_, _ fn.Option[tlv.Blob]) (bool, error) {
144144

145145
return true, nil
146146
}

0 commit comments

Comments
 (0)