routing/pathfind: simplify cltv calculation

This commit is contained in:
Conner Fromknecht 2019-12-18 23:55:47 -08:00
parent b97adf79a4
commit e3a9603846
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -166,8 +166,7 @@ func newRoute(sourceVertex route.Vertex,
// final CLTV delta value instead of the value from the // final CLTV delta value instead of the value from the
// last link in the route. // last link in the route.
totalTimeLock += uint32(finalHop.cltvDelta) totalTimeLock += uint32(finalHop.cltvDelta)
outgoingTimeLock = totalTimeLock
outgoingTimeLock = currentHeight + uint32(finalHop.cltvDelta)
} 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.
@ -180,18 +179,11 @@ func newRoute(sourceVertex route.Vertex,
// the next hop. // the next hop.
fee = pathEdges[i+1].ComputeFee(amtToForward) fee = pathEdges[i+1].ComputeFee(amtToForward)
// Next, increment the total timelock of the entire // We'll take the total timelock of the preceding hop as
// route such that each hops time lock increases as we // the outgoing timelock or this hop. Then we'll
// walk backwards in the route, using the delta of the // increment the total timelock incurred by this hop.
// previous hop. outgoingTimeLock = totalTimeLock
delta := uint32(pathEdges[i+1].TimeLockDelta) totalTimeLock += uint32(pathEdges[i+1].TimeLockDelta)
totalTimeLock += delta
// Otherwise, the value of the outgoing time-lock will
// be the value of the time-lock for the _outgoing_
// HTLC, so we factor in their specified grace period
// (time lock delta).
outgoingTimeLock = totalTimeLock - delta
} }
// Since we're traversing the path backwards atm, we prepend // Since we're traversing the path backwards atm, we prepend