Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thomash-acinq committed Mar 5, 2025
1 parent cabeb54 commit 980d8b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
12 changes: 2 additions & 10 deletions eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 980d8b4

Please sign in to comment.