From 980d8b4003670b1b2f7ac05604f385638e84a196 Mon Sep 17 00:00:00 2001 From: Thomas HUET Date: Wed, 5 Mar 2025 12:06:30 +0100 Subject: [PATCH] comments --- .../main/scala/fr/acinq/eclair/router/Graph.scala | 12 ++---------- .../main/scala/fr/acinq/eclair/router/Router.scala | 4 ---- .../scala/fr/acinq/eclair/router/GraphSpec.scala | 10 +++++----- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala b/eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala index 531218fc80..832fc0d11a 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala @@ -436,6 +436,7 @@ object Graph { /** * Find non-overlapping (no vertices shared) payment paths that support route blinding + * This is used to build blinded routes for Bolt12 invoices where `sourceNode` is the first node of the blinded path and `targetNode` is ourself. * * @param pathsToFind Number of paths to find. We may return fewer paths if we couldn't find more non-overlapping ones. */ @@ -457,6 +458,7 @@ object Graph { case Some(path) => val weight = pathWeight(sourceNode, path, amount, currentBlockHeight, wr, includeLocalChannelCost = true) paths += WeightedPath(path, weight) + // Additional paths must keep using the source and target nodes, but shouldn't use any of the same intermediate nodes. verticesToIgnore.addAll(path.drop(1).map(_.desc.a)) case None => return paths.toSeq } @@ -747,16 +749,6 @@ object Graph { } } } - - /** - * @return a node that's very central in the graph, to be used as the first node in blinded routes. - */ - def centralNode: PublicKey = { - vertices.view.mapValues(v => { - // We only consider channels larger than 0.1 BTC and count the number of connected nodes. - v.incomingEdges.values.filter(_.capacity > Satoshi(10_000_000)).map(_.desc.a).toSet.size - }).maxBy(_._2)._1 - } } object DirectedGraph { diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala b/eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala index 93033e9208..e4bfd986ae 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala @@ -247,10 +247,6 @@ class Router(val nodeParams: NodeParams, watcher: typed.ActorRef[ZmqWatcher.Comm case Event(r: MessageRouteRequest, d) => stay() using RouteCalculation.handleMessageRouteRequest(d, nodeParams.currentBlockHeight, r, nodeParams.routerConf.messageRouteParams) - case Event(r: GetCentralNode , d) => - r.replyTo ! d.graphWithBalances.graph.centralNode - stay() - case Event(GetNodeId(replyTo, shortChannelId, isNode1), d) => replyTo ! d.channels.get(shortChannelId).map(channel => if (isNode1) channel.nodeId1 else channel.nodeId2) stay() diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/GraphSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/GraphSpec.scala index d6b847f831..c84799c77f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/GraphSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/GraphSpec.scala @@ -485,11 +485,11 @@ class GraphSpec extends AnyFunSuite { +----- B ------+ | | - A -- C -- D -- H - | | - +--- E -- F ---+ - | | - +--- G ---+ + A -- C -- D -- H --+ + | | | + +--- E -- F ---+ | + | | + +--- G -------+ */ val graph = DirectedGraph(Seq( makeEdge(1L, a, b, 0 msat, 0),