From ad0f5b31f6129de8edfa4fbeb000bc7460c9ddcf Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 12 Feb 2018 16:22:22 -0800 Subject: [PATCH] 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. --- routing/router.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/routing/router.go b/routing/router.go index ff7fde75..37df8c04 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1255,9 +1255,10 @@ func (r *ChannelRouter) FindRoutes(target *btcec.PublicKey, routes, ok := r.routeCache[rt] r.routeCacheMtx.RUnlock() - // If we already have a cached route, then we'll return it directly as - // there's no need to repeat the computation. - if ok { + // If we already have a cached route, and it contains at least the + // number of paths requested, then we'll return it directly as there's + // no need to repeat the computation. + if ok && uint32(len(routes)) >= numPaths { return routes, nil }