From ec42b9acd05fc29f8b908e836eadb27a11b8b716 Mon Sep 17 00:00:00 2001 From: MPins Date: Mon, 3 Mar 2025 07:07:14 -0300 Subject: [PATCH] routing: add logging for routes discarded due to low success probability Create the ChanIDString function to return a string representation of the route's channel IDs, formatting them in the order they appear in the route (e.g., "chanID1 -> chanID2"). Discarded routes with a success probability lower than the minimum threshold are now logged accordingly when finding a blinded path. --- routing/route/route.go | 16 ++++++++++++++++ routing/router.go | 24 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/routing/route/route.go b/routing/route/route.go index 2d62af465..b3e91a6f4 100644 --- a/routing/route/route.go +++ b/routing/route/route.go @@ -773,3 +773,19 @@ func (r *Route) String() string { b.String(), r.TotalTimeLock, ) } + +// ChanIDString returns the route's channel IDs as a formatted string. +func ChanIDString(r *Route) string { + var b strings.Builder + + for i, hop := range r.Hops { + b.WriteString(fmt.Sprintf("%v", + strconv.FormatUint(hop.ChannelID, 10), + )) + if i != len(r.Hops)-1 { + b.WriteString(" -> ") + } + } + + return b.String() +} diff --git a/routing/router.go b/routing/router.go index 8c9e145be..0ce9a1ca8 100644 --- a/routing/router.go +++ b/routing/router.go @@ -684,19 +684,27 @@ func (r *ChannelRouter) FindBlindedPaths(destination route.Vertex, prevNode = path[j].vertex } - // Don't bother adding a route if its success probability less - // minimum that can be assigned to any single pair. - if totalRouteProbability <= DefaultMinRouteProbability { - continue - } - - routes = append(routes, &routeWithProbability{ + routeWithProbability := &routeWithProbability{ route: &route.Route{ SourcePubKey: introNode, Hops: hops, }, probability: totalRouteProbability, - }) + } + + // Don't bother adding a route if its success probability less + // minimum that can be assigned to any single pair. + if totalRouteProbability <= DefaultMinRouteProbability { + log.Debugf("Not using route (%v) as a blinded "+ + "path since it resulted in an low "+ + "probability path(%.3f)", + route.ChanIDString(routeWithProbability.route), + routeWithProbability.probability, + ) + continue + } + + routes = append(routes, routeWithProbability) } // Sort the routes based on probability.