routerrpc: add HasNode backend function for LSP heuristic

This commit adds the HasNode function to the RouterBackend struct,
which checks if a node exists in the graph (i.e., has public channels).
This function is needed by the LSP detection heuristic to determine
if a node is publicly reachable.

The function is wired up in rpcserver.go to query the graph database.
This commit is contained in:
ziggie committed 2025-11-29 01:04:28 +01:00
1 parent 06886e71b2
commit 48da56b285
2 files changed
+12

No files matched your search

+5
View File
@@ -64,6 +64,11 @@ type RouterBackend struct {
FetchChannelEndpoints func(chanID uint64) (route.Vertex,
route.Vertex, error)
// HasNode returns true if the node exists in the graph (i.e., has
// public channels), false otherwise. This means the node is a public
// node and should be reachable.
HasNode func(nodePub route.Vertex) (bool, error)
// FindRoute is a closure that abstracts away how we locate/query for
// routes.
FindRoute func(*routing.RouteRequest) (*route.Route, float64, error)
+7
View File
@@ -695,6 +695,8 @@ func newRPCServer(cfg *Config, interceptorChain *rpcperms.InterceptorChain,
// addDeps populates all dependencies needed by the RPC server, and any
// of the sub-servers that it maintains. When this is done, the RPC server can
// be started, and start accepting RPC calls.
//
//nolint:funlen
func (r *rpcServer) addDeps(ctx context.Context, s *server,
macService *macaroons.Service,
subServerCgs *subRPCServerConfigs, atpl *autopilot.Manager,
@@ -744,6 +746,11 @@ func (r *rpcServer) addDeps(ctx context.Context, s *server,
return info.NodeKey1Bytes, info.NodeKey2Bytes, nil
},
HasNode: func(nodePub route.Vertex) (bool, error) {
_, exists, err := graph.HasNode(ctx, nodePub)
return exists, err
},
FindRoute: s.chanRouter.FindRoute,
MissionControl: s.defaultMC,
ActiveNetParams: r.cfg.ActiveNetParams.Params,