Skip to content

Commit b628483

Browse files
committed
routing: update TLV traffic shaper interface
1 parent 1404468 commit b628483

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

routing/bandwidth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package routing
33
import (
44
"fmt"
55

6-
"github.com/btcsuite/btcd/btcutil"
76
"github.com/lightningnetwork/lnd/channeldb"
87
"github.com/lightningnetwork/lnd/fn"
98
"github.com/lightningnetwork/lnd/htlcswitch"
@@ -55,7 +54,8 @@ type AuxHtlcModifier interface {
5554
// data blob of an HTLC, may produce a different blob or modify the
5655
// amount of bitcoin this htlc should carry.
5756
ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
58-
htlcBlob tlv.Blob) (btcutil.Amount, tlv.Blob, error)
57+
htlcCustomRecords lnwire.CustomRecords) (lnwire.MilliSatoshi,
58+
tlv.Blob, error)
5959
}
6060

6161
// getLinkQuery is the function signature used to lookup a link.

routing/payment_lifecycle.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -679,23 +679,13 @@ func (p *paymentLifecycle) sendAttempt(
679679
CustomRecords: lnwire.CustomRecords(p.firstHopTLVs),
680680
}
681681

682-
// If we had custom records in the HTLC, then we'll encode that here
683-
// now. We allow the traffic shaper (if there is one) to overwrite the
684-
// custom records below. But if there is no traffic shaper, we still
685-
// want to forward these custom records.
686-
encodedRecords, err := htlcAdd.CustomRecords.Serialize()
687-
if err != nil {
688-
return nil, fmt.Errorf("unable to encode first hop TLVs: %w",
689-
err)
690-
}
691-
692682
// If a hook exists that may affect our outgoing message, we call it now
693683
// and apply its side effects to the UpdateAddHTLC message.
694-
err = fn.MapOptionZ(
684+
err := fn.MapOptionZ(
695685
p.router.cfg.TrafficShaper,
696686
func(ts TlvTrafficShaper) error {
697687
newAmt, newData, err := ts.ProduceHtlcExtraData(
698-
rt.TotalAmount, encodedRecords,
688+
rt.TotalAmount, htlcAdd.CustomRecords,
699689
)
700690
if err != nil {
701691
return err
@@ -706,8 +696,12 @@ func (p *paymentLifecycle) sendAttempt(
706696
return err
707697
}
708698

699+
log.Debugf("TLV traffic shaper returned custom "+
700+
"records %v and amount %d msat for HTLC",
701+
spew.Sdump(customRecords), newAmt)
702+
709703
htlcAdd.CustomRecords = customRecords
710-
htlcAdd.Amount = lnwire.NewMSatFromSatoshis(newAmt)
704+
htlcAdd.Amount = newAmt
711705

712706
return nil
713707
},

0 commit comments

Comments
 (0)