routing: return cached route response in FindRoutes if enough routes
In this commit, we modify the caching structure to return a set of cached routes for a request if the number of routes requested is less than or equal to the number of cached of routes.
This commit is contained in:
parent
8a29c01354
commit
ad0f5b31f6
@ -1255,9 +1255,10 @@ func (r *ChannelRouter) FindRoutes(target *btcec.PublicKey,
|
|||||||
routes, ok := r.routeCache[rt]
|
routes, ok := r.routeCache[rt]
|
||||||
r.routeCacheMtx.RUnlock()
|
r.routeCacheMtx.RUnlock()
|
||||||
|
|
||||||
// If we already have a cached route, then we'll return it directly as
|
// If we already have a cached route, and it contains at least the
|
||||||
// there's no need to repeat the computation.
|
// number of paths requested, then we'll return it directly as there's
|
||||||
if ok {
|
// no need to repeat the computation.
|
||||||
|
if ok && uint32(len(routes)) >= numPaths {
|
||||||
return routes, nil
|
return routes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user