Merge pull request #2128 from mrfelton/fix/queryroutes-default-num-routes
queryroutes: set queryroutes numRoutes param default to 10
This commit is contained in:
commit
b4e4f40125
18
rpcserver.go
18
rpcserver.go
@ -3657,6 +3657,12 @@ func (r *rpcServer) QueryRoutes(ctx context.Context,
|
|||||||
|
|
||||||
feeLimit := calculateFeeLimit(in.FeeLimit, amtMSat)
|
feeLimit := calculateFeeLimit(in.FeeLimit, amtMSat)
|
||||||
|
|
||||||
|
// numRoutes will default to 10 if not specified explicitly.
|
||||||
|
numRoutesIn := uint32(in.NumRoutes)
|
||||||
|
if numRoutesIn == 0 {
|
||||||
|
numRoutesIn = 10
|
||||||
|
}
|
||||||
|
|
||||||
// Query the channel router for a possible path to the destination that
|
// Query the channel router for a possible path to the destination that
|
||||||
// can carry `in.Amt` satoshis _including_ the total fee required on
|
// can carry `in.Amt` satoshis _including_ the total fee required on
|
||||||
// the route.
|
// the route.
|
||||||
@ -3666,11 +3672,11 @@ func (r *rpcServer) QueryRoutes(ctx context.Context,
|
|||||||
)
|
)
|
||||||
if in.FinalCltvDelta == 0 {
|
if in.FinalCltvDelta == 0 {
|
||||||
routes, findErr = r.server.chanRouter.FindRoutes(
|
routes, findErr = r.server.chanRouter.FindRoutes(
|
||||||
pubKey, amtMSat, feeLimit, uint32(in.NumRoutes),
|
pubKey, amtMSat, feeLimit, numRoutesIn,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
routes, findErr = r.server.chanRouter.FindRoutes(
|
routes, findErr = r.server.chanRouter.FindRoutes(
|
||||||
pubKey, amtMSat, feeLimit, uint32(in.NumRoutes),
|
pubKey, amtMSat, feeLimit, numRoutesIn,
|
||||||
uint16(in.FinalCltvDelta),
|
uint16(in.FinalCltvDelta),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -3681,9 +3687,9 @@ func (r *rpcServer) QueryRoutes(ctx context.Context,
|
|||||||
// As the number of returned routes can be less than the number of
|
// As the number of returned routes can be less than the number of
|
||||||
// requested routes, we'll clamp down the length of the response to the
|
// requested routes, we'll clamp down the length of the response to the
|
||||||
// minimum of the two.
|
// minimum of the two.
|
||||||
numRoutes := int32(len(routes))
|
numRoutes := uint32(len(routes))
|
||||||
if in.NumRoutes < numRoutes {
|
if numRoutesIn < numRoutes {
|
||||||
numRoutes = in.NumRoutes
|
numRoutes = numRoutesIn
|
||||||
}
|
}
|
||||||
|
|
||||||
// For each valid route, we'll convert the result into the format
|
// For each valid route, we'll convert the result into the format
|
||||||
@ -3691,7 +3697,7 @@ func (r *rpcServer) QueryRoutes(ctx context.Context,
|
|||||||
routeResp := &lnrpc.QueryRoutesResponse{
|
routeResp := &lnrpc.QueryRoutesResponse{
|
||||||
Routes: make([]*lnrpc.Route, 0, in.NumRoutes),
|
Routes: make([]*lnrpc.Route, 0, in.NumRoutes),
|
||||||
}
|
}
|
||||||
for i := int32(0); i < numRoutes; i++ {
|
for i := uint32(0); i < numRoutes; i++ {
|
||||||
routeResp.Routes = append(
|
routeResp.Routes = append(
|
||||||
routeResp.Routes, r.marshallRoute(routes[i]),
|
routeResp.Routes, r.marshallRoute(routes[i]),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user