routerrpc: report route success probability
The intention of adding this field is to make probability based path finding more transparent and help understand why a route is returned.
This commit is contained in:
4 files changed
+578
-519
No files matched your search
@@ -231,13 +231,41 @@ func (r *RouterBackend) QueryRoutes(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate route success probability. Do not rely on a probability
|
||||||
|
// that could have been returned from path finding, because mission
|
||||||
|
// control may have been disabled in the provided ProbabilitySource.
|
||||||
|
successProb := r.getSuccessProbability(route)
|
||||||
|
|
||||||
routeResp := &lnrpc.QueryRoutesResponse{
|
routeResp := &lnrpc.QueryRoutesResponse{
|
||||||
Routes: []*lnrpc.Route{rpcRoute},
|
Routes: []*lnrpc.Route{rpcRoute},
|
||||||
|
SuccessProb: successProb,
|
||||||
}
|
}
|
||||||
|
|
||||||
return routeResp, nil
|
return routeResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getSuccessProbability returns the success probability for the given route
|
||||||
|
// based on the current state of mission control.
|
||||||
|
func (r *RouterBackend) getSuccessProbability(rt *route.Route) float64 {
|
||||||
|
fromNode := rt.SourcePubKey
|
||||||
|
amtToFwd := rt.TotalAmount
|
||||||
|
successProb := 1.0
|
||||||
|
for _, hop := range rt.Hops {
|
||||||
|
toNode := hop.PubKeyBytes
|
||||||
|
|
||||||
|
probability := r.MissionControl.GetProbability(
|
||||||
|
fromNode, toNode, amtToFwd,
|
||||||
|
)
|
||||||
|
|
||||||
|
successProb *= probability
|
||||||
|
|
||||||
|
amtToFwd = hop.AmtToForward
|
||||||
|
fromNode = toNode
|
||||||
|
}
|
||||||
|
|
||||||
|
return successProb
|
||||||
|
}
|
||||||
|
|
||||||
// rpcEdgeToPair looks up the provided channel and returns the channel endpoints
|
// rpcEdgeToPair looks up the provided channel and returns the channel endpoints
|
||||||
// as a directed pair.
|
// as a directed pair.
|
||||||
func (r *RouterBackend) rpcEdgeToPair(e *lnrpc.EdgeLocator) (
|
func (r *RouterBackend) rpcEdgeToPair(e *lnrpc.EdgeLocator) (
|
||||||
|
|||||||
+532
-517
File diff suppressed because it is too large.
Load diff
@@ -1704,7 +1704,17 @@ message EdgeLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message QueryRoutesResponse {
|
message QueryRoutesResponse {
|
||||||
|
/**
|
||||||
|
The route that results from the path finding operation. This is still a
|
||||||
|
repeated field to retain backwards compatibility.
|
||||||
|
*/
|
||||||
repeated Route routes = 1 [json_name = "routes"];
|
repeated Route routes = 1 [json_name = "routes"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
The success probability of the returned route based on the current mission
|
||||||
|
control state. [EXPERIMENTAL]
|
||||||
|
*/
|
||||||
|
double success_prob = 2 [json_name = "success_prob"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message Hop {
|
message Hop {
|
||||||
|
|||||||
@@ -3163,7 +3163,13 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/lnrpcRoute"
|
"$ref": "#/definitions/lnrpcRoute"
|
||||||
}
|
},
|
||||||
|
"description": "*\nThe route that results from the path finding operation. This is still a\nrepeated field to retain backwards compatibility."
|
||||||
|
},
|
||||||
|
"success_prob": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "double",
|
||||||
|
"title": "*\nThe success probability of the returned route based on the current mission\ncontrol state. [EXPERIMENTAL]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user