-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
routing: don't set custom amount if manager isn't handling #9502
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3443,9 +3443,13 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy, | |
return NewLinkError(&lnwire.FailTemporaryNodeFailure{}) | ||
} | ||
|
||
auxBandwidth.WhenSome(func(bandwidth lnwire.MilliSatoshi) { | ||
availableBandwidth = bandwidth | ||
}) | ||
if auxBandwidth.IsHandled && auxBandwidth.Bandwidth.IsSome() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this second arg ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this is super-defensive I guess. More for the reader of the code than the compiler. But can remove if you feel it has the opposite effect, reducing clarity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh ok yeah let's keep it then. |
||
auxBandwidth.Bandwidth.WhenSome( | ||
func(bandwidth lnwire.MilliSatoshi) { | ||
availableBandwidth = bandwidth | ||
}, | ||
) | ||
} | ||
|
||
// Check to see if there is enough balance in this channel. | ||
if amt > availableBandwidth { | ||
|
@@ -3471,8 +3475,6 @@ func (l *channelLink) AuxBandwidth(amount lnwire.MilliSatoshi, | |
cid lnwire.ShortChannelID, htlcBlob fn.Option[tlv.Blob], | ||
ts AuxTrafficShaper) fn.Result[OptionalBandwidth] { | ||
|
||
unknownBandwidth := fn.None[lnwire.MilliSatoshi]() | ||
|
||
fundingBlob := l.FundingCustomBlob() | ||
shouldHandle, err := ts.ShouldHandleTraffic(cid, fundingBlob) | ||
if err != nil { | ||
|
@@ -3486,7 +3488,9 @@ func (l *channelLink) AuxBandwidth(amount lnwire.MilliSatoshi, | |
// If this channel isn't handled by the aux traffic shaper, we'll return | ||
// early. | ||
if !shouldHandle { | ||
return fn.Ok(unknownBandwidth) | ||
return fn.Ok(OptionalBandwidth{ | ||
IsHandled: false, | ||
}) | ||
} | ||
|
||
// Ask for a specific bandwidth to be used for the channel. | ||
|
@@ -3502,7 +3506,10 @@ func (l *channelLink) AuxBandwidth(amount lnwire.MilliSatoshi, | |
log.Debugf("ShortChannelID=%v: aux traffic shaper reported available "+ | ||
"bandwidth: %v", cid, auxBandwidth) | ||
|
||
return fn.Ok(fn.Some(auxBandwidth)) | ||
return fn.Ok(OptionalBandwidth{ | ||
IsHandled: true, | ||
Bandwidth: fn.Some(auxBandwidth), | ||
}) | ||
} | ||
|
||
// Stats returns the statistics of channel link. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when does this set to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, good catch. Copy/paste mistake. Fixed!
We'll validate all of this with an integration test in
litd
. Unfortunately we aren't really set up to test these things properly in unit or integration tests with inlnd
(but probably worth the investment very soon).