mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-24 06:47:44 +01:00
routing: pass link bandwidth to traffic shaper's bandwidth query
This commit updates the traffic shaper's bandwidth query method to accept the link bandwidth as a parameter. This allows an external traffic shaper to optionally return the link bandwidth as the payment bandwidth.
This commit is contained in:
parent
393d6829ca
commit
29a12c28c9
1 changed files with 9 additions and 4 deletions
|
@ -43,8 +43,8 @@ type TlvTrafficShaper interface {
|
||||||
// of 0 means there is no bandwidth available. To find out if a channel
|
// of 0 means there is no bandwidth available. To find out if a channel
|
||||||
// is a custom channel that should be handled by the traffic shaper, the
|
// is a custom channel that should be handled by the traffic shaper, the
|
||||||
// HandleTraffic method should be called first.
|
// HandleTraffic method should be called first.
|
||||||
PaymentBandwidth(htlcBlob,
|
PaymentBandwidth(htlcBlob, commitmentBlob fn.Option[tlv.Blob],
|
||||||
commitmentBlob fn.Option[tlv.Blob]) (lnwire.MilliSatoshi, error)
|
linkBandwidth lnwire.MilliSatoshi) (lnwire.MilliSatoshi, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuxHtlcModifier is an interface that allows the sender to modify the outgoing
|
// AuxHtlcModifier is an interface that allows the sender to modify the outgoing
|
||||||
|
@ -131,6 +131,11 @@ func (b *bandwidthManager) getBandwidth(cid lnwire.ShortChannelID,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// We will pass the link bandwidth to the external traffic
|
||||||
|
// shaper. This is the current best estimate for the available
|
||||||
|
// bandwidth for the link.
|
||||||
|
linkBandwidth = link.Bandwidth()
|
||||||
|
|
||||||
auxBandwidth lnwire.MilliSatoshi
|
auxBandwidth lnwire.MilliSatoshi
|
||||||
auxBandwidthDetermined bool
|
auxBandwidthDetermined bool
|
||||||
)
|
)
|
||||||
|
@ -154,7 +159,7 @@ func (b *bandwidthManager) getBandwidth(cid lnwire.ShortChannelID,
|
||||||
// Ask for a specific bandwidth to be used for the channel.
|
// Ask for a specific bandwidth to be used for the channel.
|
||||||
commitmentBlob := link.CommitmentCustomBlob()
|
commitmentBlob := link.CommitmentCustomBlob()
|
||||||
auxBandwidth, err = ts.PaymentBandwidth(
|
auxBandwidth, err = ts.PaymentBandwidth(
|
||||||
htlcBlob, commitmentBlob,
|
htlcBlob, commitmentBlob, linkBandwidth,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get bandwidth from "+
|
return fmt.Errorf("failed to get bandwidth from "+
|
||||||
|
@ -192,7 +197,7 @@ func (b *bandwidthManager) getBandwidth(cid lnwire.ShortChannelID,
|
||||||
|
|
||||||
// Otherwise, we'll return the current best estimate for the
|
// Otherwise, we'll return the current best estimate for the
|
||||||
// available bandwidth for the link.
|
// available bandwidth for the link.
|
||||||
return link.Bandwidth()
|
return linkBandwidth
|
||||||
}
|
}
|
||||||
|
|
||||||
// availableChanBandwidth returns the total available bandwidth for a channel
|
// availableChanBandwidth returns the total available bandwidth for a channel
|
||||||
|
|
Loading…
Add table
Reference in a new issue