mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-12 09:52:14 +02:00
Merge pull request #9727 from guggero/strict-forwarding
Aux bandwidth manager: also pass HTLC blob to `ShouldHandleTraffic`
This commit is contained in:
commit
c25f98f5b9
@ -509,7 +509,7 @@ type AuxTrafficShaper interface {
|
|||||||
// identified by the provided channel ID may have external mechanisms
|
// identified by the provided channel ID may have external mechanisms
|
||||||
// that would allow it to carry out the payment.
|
// that would allow it to carry out the payment.
|
||||||
ShouldHandleTraffic(cid lnwire.ShortChannelID,
|
ShouldHandleTraffic(cid lnwire.ShortChannelID,
|
||||||
fundingBlob fn.Option[tlv.Blob]) (bool, error)
|
fundingBlob, htlcBlob fn.Option[tlv.Blob]) (bool, error)
|
||||||
|
|
||||||
// PaymentBandwidth returns the available bandwidth for a custom channel
|
// PaymentBandwidth returns the available bandwidth for a custom channel
|
||||||
// decided by the given channel aux blob and HTLC blob. A return value
|
// decided by the given channel aux blob and HTLC blob. A return value
|
||||||
|
@ -3484,7 +3484,7 @@ func (l *channelLink) AuxBandwidth(amount lnwire.MilliSatoshi,
|
|||||||
ts AuxTrafficShaper) fn.Result[OptionalBandwidth] {
|
ts AuxTrafficShaper) fn.Result[OptionalBandwidth] {
|
||||||
|
|
||||||
fundingBlob := l.FundingCustomBlob()
|
fundingBlob := l.FundingCustomBlob()
|
||||||
shouldHandle, err := ts.ShouldHandleTraffic(cid, fundingBlob)
|
shouldHandle, err := ts.ShouldHandleTraffic(cid, fundingBlob, htlcBlob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fn.Err[OptionalBandwidth](fmt.Errorf("traffic shaper "+
|
return fn.Err[OptionalBandwidth](fmt.Errorf("traffic shaper "+
|
||||||
"failed to decide whether to handle traffic: %w", err))
|
"failed to decide whether to handle traffic: %w", err))
|
||||||
|
@ -1149,6 +1149,9 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
|||||||
func (s *Switch) checkCircularForward(incoming, outgoing lnwire.ShortChannelID,
|
func (s *Switch) checkCircularForward(incoming, outgoing lnwire.ShortChannelID,
|
||||||
allowCircular bool, paymentHash lntypes.Hash) *LinkError {
|
allowCircular bool, paymentHash lntypes.Hash) *LinkError {
|
||||||
|
|
||||||
|
log.Tracef("Checking for circular route: incoming=%v, outgoing=%v "+
|
||||||
|
"(payment hash: %x)", incoming, outgoing, paymentHash[:])
|
||||||
|
|
||||||
// If they are equal, we can skip the alias mapping checks.
|
// If they are equal, we can skip the alias mapping checks.
|
||||||
if incoming == outgoing {
|
if incoming == outgoing {
|
||||||
// The switch may be configured to allow circular routes, so
|
// The switch may be configured to allow circular routes, so
|
||||||
@ -1189,6 +1192,10 @@ func (s *Switch) checkCircularForward(incoming, outgoing lnwire.ShortChannelID,
|
|||||||
|
|
||||||
// Check base SCID equality.
|
// Check base SCID equality.
|
||||||
if incomingBaseScid != outgoingBaseScid {
|
if incomingBaseScid != outgoingBaseScid {
|
||||||
|
log.Tracef("Incoming base SCID %v does not match outgoing "+
|
||||||
|
"base SCID %v (payment hash: %x)", incomingBaseScid,
|
||||||
|
outgoingBaseScid, paymentHash[:])
|
||||||
|
|
||||||
// The base SCIDs are not equal so these are not the same
|
// The base SCIDs are not equal so these are not the same
|
||||||
// channel.
|
// channel.
|
||||||
return nil
|
return nil
|
||||||
|
@ -140,7 +140,7 @@ type mockTrafficShaper struct{}
|
|||||||
// by the provided channel ID may have external mechanisms that would
|
// by the provided channel ID may have external mechanisms that would
|
||||||
// allow it to carry out the payment.
|
// allow it to carry out the payment.
|
||||||
func (*mockTrafficShaper) ShouldHandleTraffic(_ lnwire.ShortChannelID,
|
func (*mockTrafficShaper) ShouldHandleTraffic(_ lnwire.ShortChannelID,
|
||||||
_ fn.Option[tlv.Blob]) (bool, error) {
|
_, _ fn.Option[tlv.Blob]) (bool, error) {
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user