routing: pass BlindedPaymentPathSet around everywhere

Building on from the previous commit, here we pass the PathSet around
everywhere where we previously passed around the single BlindedPayment.
This commit is contained in:
Elle Mouton
2024-05-15 15:08:19 +02:00
parent 3d5f20b70f
commit 4a22ec8413
7 changed files with 94 additions and 92 deletions

View File

@@ -136,9 +136,8 @@ type finalHopParams struct {
// NOTE: If a non-nil blinded path is provided it is assumed to have been
// validated by the caller.
func newRoute(sourceVertex route.Vertex,
pathEdges []*unifiedEdge, currentHeight uint32,
finalHop finalHopParams, blindedPath *sphinx.BlindedPath) (
*route.Route, error) {
pathEdges []*unifiedEdge, currentHeight uint32, finalHop finalHopParams,
blindedPathSet *BlindedPaymentPathSet) (*route.Route, error) {
var (
hops []*route.Hop
@@ -153,8 +152,14 @@ func newRoute(sourceVertex route.Vertex,
// backwards below, this next hop gets closer and closer to the
// sender of the payment.
nextIncomingAmount lnwire.MilliSatoshi
blindedPath *sphinx.BlindedPath
)
if blindedPathSet != nil {
blindedPath = blindedPathSet.GetPath().BlindedPath
}
pathLength := len(pathEdges)
for i := pathLength - 1; i >= 0; i-- {
// Now we'll start to calculate the items within the per-hop
@@ -437,9 +442,9 @@ type RestrictParams struct {
// the payee.
Metadata []byte
// BlindedPayment is necessary to determine the hop size of the
// BlindedPaymentPathSet is necessary to determine the hop size of the
// last/exit hop.
BlindedPayment *BlindedPayment
BlindedPaymentPathSet *BlindedPaymentPathSet
}
// PathFindingConfig defines global parameters that control the trade-off in
@@ -1365,9 +1370,11 @@ func getProbabilityBasedDist(weight int64, probability float64,
func lastHopPayloadSize(r *RestrictParams, finalHtlcExpiry int32,
amount lnwire.MilliSatoshi) uint64 {
if r.BlindedPayment != nil {
blindedPath := r.BlindedPayment.BlindedPath.BlindedHops
blindedPoint := r.BlindedPayment.BlindedPath.BlindingPoint
if r.BlindedPaymentPathSet != nil {
paymentPath := r.BlindedPaymentPathSet.
LargestLastHopPayloadPath()
blindedPath := paymentPath.BlindedPath.BlindedHops
blindedPoint := paymentPath.BlindedPath.BlindingPoint
encryptedData := blindedPath[len(blindedPath)-1].CipherText
finalHop := route.Hop{