mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
htlcswitch: modify Bandwidth() method on links to use more accurate accoutning
In this commit, we modify the existing implementation of the Bandwidth() method on the default ChannelLink implementation to use much tighter accounting. Before this commit, there was a bug wherein if the link restarted with pending un-settled HTLC’s, and one of them was settled, then the bandwidth wouldn’t properly be updated to reflect this fact. To fix this, we’ve done away with the manual accounting and instead grab the current balances from two sources: the set of active HTLC’s within the overflow queue, and the report from the link itself which includes the pending HTLC’s and factors in the amount we’d need to (or not need to) pay in fees for each HTLC.
This commit is contained in:
@@ -51,6 +51,7 @@ type htlcPacket struct {
|
||||
func newInitPacket(destNode [33]byte, htlc *lnwire.UpdateAddHTLC) *htlcPacket {
|
||||
return &htlcPacket{
|
||||
destNode: destNode,
|
||||
amount: htlc.Amount,
|
||||
htlc: htlc,
|
||||
}
|
||||
}
|
||||
@@ -61,6 +62,7 @@ func newAddPacket(src, dest lnwire.ShortChannelID,
|
||||
htlc *lnwire.UpdateAddHTLC, e ErrorEncrypter) *htlcPacket {
|
||||
|
||||
return &htlcPacket{
|
||||
amount: htlc.Amount,
|
||||
dest: dest,
|
||||
src: src,
|
||||
htlc: htlc,
|
||||
|
Reference in New Issue
Block a user