mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 19:22:40 +01:00
routing/pathfind: consolidate population of custom records
This commit is contained in:
parent
cddb71ee53
commit
7965cb08db
@ -151,6 +151,7 @@ func newRoute(sourceVertex route.Vertex,
|
|||||||
fee lnwire.MilliSatoshi
|
fee lnwire.MilliSatoshi
|
||||||
outgoingTimeLock uint32
|
outgoingTimeLock uint32
|
||||||
tlvPayload bool
|
tlvPayload bool
|
||||||
|
customRecords record.CustomSet
|
||||||
)
|
)
|
||||||
|
|
||||||
// Define a helper function that checks this edge's feature
|
// Define a helper function that checks this edge's feature
|
||||||
@ -182,6 +183,14 @@ func newRoute(sourceVertex route.Vertex,
|
|||||||
// last link in the route.
|
// last link in the route.
|
||||||
totalTimeLock += uint32(finalHop.cltvDelta)
|
totalTimeLock += uint32(finalHop.cltvDelta)
|
||||||
outgoingTimeLock = totalTimeLock
|
outgoingTimeLock = totalTimeLock
|
||||||
|
|
||||||
|
// Attach any custom records to the final hop if the
|
||||||
|
// receiver supports TLV.
|
||||||
|
if !tlvPayload && finalHop.records != nil {
|
||||||
|
return nil, errors.New("cannot attach " +
|
||||||
|
"custom records")
|
||||||
|
}
|
||||||
|
customRecords = finalHop.records
|
||||||
} else {
|
} else {
|
||||||
// The amount that the current hop needs to forward is
|
// The amount that the current hop needs to forward is
|
||||||
// equal to the incoming amount of the next hop.
|
// equal to the incoming amount of the next hop.
|
||||||
@ -210,12 +219,7 @@ func newRoute(sourceVertex route.Vertex,
|
|||||||
AmtToForward: amtToForward,
|
AmtToForward: amtToForward,
|
||||||
OutgoingTimeLock: outgoingTimeLock,
|
OutgoingTimeLock: outgoingTimeLock,
|
||||||
LegacyPayload: !tlvPayload,
|
LegacyPayload: !tlvPayload,
|
||||||
}
|
CustomRecords: customRecords,
|
||||||
|
|
||||||
// If this is the last hop, then we'll populate any TLV records
|
|
||||||
// destined for it.
|
|
||||||
if i == len(pathEdges)-1 && len(finalHop.records) != 0 {
|
|
||||||
currentHop.CustomRecords = finalHop.records
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hops = append([]*route.Hop{currentHop}, hops...)
|
hops = append([]*route.Hop{currentHop}, hops...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user