routing: extend missionControl.RequestRoute to take final CLTV delta

This commit is contained in:
Olaoluwa Osuntokun 2017-10-22 17:28:18 -07:00
parent 828057889e
commit 76ec41103e
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 7 additions and 6 deletions

@ -67,13 +67,13 @@ type missionControl struct {
// //
// TODO(roasbeef): persist memory // TODO(roasbeef): persist memory
func newMissionControl(g *channeldb.ChannelGraph, func newMissionControl(g *channeldb.ChannelGraph,
s *channeldb.LightningNode) *missionControl { selfNode *channeldb.LightningNode) *missionControl {
return &missionControl{ return &missionControl{
graph: g,
selfNode: s,
failedEdges: make(map[uint64]time.Time), failedEdges: make(map[uint64]time.Time),
failedVertexes: make(map[vertex]time.Time), failedVertexes: make(map[vertex]time.Time),
selfNode: selfNode,
graph: g,
} }
} }
@ -111,7 +111,7 @@ func (m *missionControl) ReportChannelFailure(e uint64) {
// //
// NOTE: This function is safe for concurrent access. // NOTE: This function is safe for concurrent access.
func (m *missionControl) RequestRoute(payment *LightningPayment, func (m *missionControl) RequestRoute(payment *LightningPayment,
height uint32) (*Route, error) { height uint32, finalCltvDelta uint16) (*Route, error) {
// First, we'll query mission control for it's current recommendation // First, we'll query mission control for it's current recommendation
// on the edges/vertexes to ignore during path finding. // on the edges/vertexes to ignore during path finding.
@ -131,7 +131,8 @@ func (m *missionControl) RequestRoute(payment *LightningPayment,
// With the next candidate path found, we'll attempt to turn this into // With the next candidate path found, we'll attempt to turn this into
// a route by applying the time-lock and fee requirements. // a route by applying the time-lock and fee requirements.
sourceVertex := newVertex(m.selfNode.PubKey) sourceVertex := newVertex(m.selfNode.PubKey)
route, err := newRoute(payment.Amount, sourceVertex, path, height) route, err := newRoute(payment.Amount, sourceVertex, path, height,
finalCltvDelta)
if err != nil { if err != nil {
// TODO(roasbeef): return which edge/vertex didn't work // TODO(roasbeef): return which edge/vertex didn't work
// out // out

@ -1216,7 +1216,7 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route
// state of the channel graph and our past HTLC routing // state of the channel graph and our past HTLC routing
// successes/failures. // successes/failures.
route, err := r.missionControl.RequestRoute(payment, route, err := r.missionControl.RequestRoute(payment,
uint32(currentHeight)) uint32(currentHeight), finalCLTVDelta)
if err != nil { if err != nil {
// If we're unable to successfully make a payment using // If we're unable to successfully make a payment using
// any of the routes we've found, then return an error. // any of the routes we've found, then return an error.