From 5d5cfe36c7bb892b3ae1d61ce8e854fe893fa963 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Thu, 13 Feb 2025 08:35:56 +0200 Subject: [PATCH] routing: rename routing Graph method In preparation for having the ChannelGraph directly implement the `routing.Graph` interface, we rename the `ForEachNodeChannel` method to `ForEachNodeDirectedChannel` since the ChannelGraph already uses the `ForEachNodeChannel` name and the new name is more appropriate since the ChannelGraph currently has a `ForEachNodeDirectedChannelTx` method which passes the same DirectedChannel type to the given call-back. --- graph/graphsession/graph_session.go | 5 +++-- routing/bandwidth.go | 2 +- routing/graph.go | 6 +++--- routing/integrated_routing_context_test.go | 2 +- routing/mock_graph_test.go | 2 +- routing/pathfind.go | 4 ++-- routing/unified_edges.go | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/graph/graphsession/graph_session.go b/graph/graphsession/graph_session.go index 786303d2e..31265ff56 100644 --- a/graph/graphsession/graph_session.go +++ b/graph/graphsession/graph_session.go @@ -80,10 +80,11 @@ func (g *session) close() error { return nil } -// ForEachNodeChannel calls the callback for every channel of the given node. +// ForEachNodeDirectedChannel calls the callback for every channel of the given +// node. // // NOTE: Part of the routing.Graph interface. -func (g *session) ForEachNodeChannel(nodePub route.Vertex, +func (g *session) ForEachNodeDirectedChannel(nodePub route.Vertex, cb func(channel *graphdb.DirectedChannel) error) error { return g.graph.ForEachNodeDirectedChannelTx(g.tx, nodePub, cb) diff --git a/routing/bandwidth.go b/routing/bandwidth.go index a552628c7..833782616 100644 --- a/routing/bandwidth.go +++ b/routing/bandwidth.go @@ -63,7 +63,7 @@ func newBandwidthManager(graph Graph, sourceNode route.Vertex, // First, we'll collect the set of outbound edges from the target // source node and add them to our bandwidth manager's map of channels. - err := graph.ForEachNodeChannel(sourceNode, + err := graph.ForEachNodeDirectedChannel(sourceNode, func(channel *graphdb.DirectedChannel) error { shortID := lnwire.NewShortChanIDFromInt( channel.ChannelID, diff --git a/routing/graph.go b/routing/graph.go index 7608ee92b..fa1e7eb1d 100644 --- a/routing/graph.go +++ b/routing/graph.go @@ -12,9 +12,9 @@ import ( // Graph is an abstract interface that provides information about nodes and // edges to pathfinding. type Graph interface { - // ForEachNodeChannel calls the callback for every channel of the given - // node. - ForEachNodeChannel(nodePub route.Vertex, + // ForEachNodeDirectedChannel calls the callback for every channel of + // the given node. + ForEachNodeDirectedChannel(nodePub route.Vertex, cb func(channel *graphdb.DirectedChannel) error) error // FetchNodeFeatures returns the features of the given node. diff --git a/routing/integrated_routing_context_test.go b/routing/integrated_routing_context_test.go index c11b055d9..1402ce9e4 100644 --- a/routing/integrated_routing_context_test.go +++ b/routing/integrated_routing_context_test.go @@ -391,7 +391,7 @@ func (g *mockGraphSessionChanDB) close() error { return nil } -func (g *mockGraphSessionChanDB) ForEachNodeChannel(nodePub route.Vertex, +func (g *mockGraphSessionChanDB) ForEachNodeDirectedChannel(nodePub route.Vertex, cb func(channel *graphdb.DirectedChannel) error) error { return g.graph.ForEachNodeDirectedChannelTx(g.tx, nodePub, cb) diff --git a/routing/mock_graph_test.go b/routing/mock_graph_test.go index cab7c9726..68dc1e80a 100644 --- a/routing/mock_graph_test.go +++ b/routing/mock_graph_test.go @@ -165,7 +165,7 @@ func (m *mockGraph) addChannel(id uint64, node1id, node2id byte, // forEachNodeChannel calls the callback for every channel of the given node. // // NOTE: Part of the Graph interface. -func (m *mockGraph) ForEachNodeChannel(nodePub route.Vertex, +func (m *mockGraph) ForEachNodeDirectedChannel(nodePub route.Vertex, cb func(channel *graphdb.DirectedChannel) error) error { // Look up the mock node. diff --git a/routing/pathfind.go b/routing/pathfind.go index 3f1d0ba09..c14e32e8b 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -557,7 +557,7 @@ func getOutgoingBalance(node route.Vertex, outgoingChans map[uint64]struct{}, } // Iterate over all channels of the to node. - err := g.ForEachNodeChannel(node, cb) + err := g.ForEachNodeDirectedChannel(node, cb) if err != nil { return 0, 0, err } @@ -1325,7 +1325,7 @@ func processNodeForBlindedPath(g Graph, node route.Vertex, // Now, iterate over the node's channels in search for paths to this // node that can be used for blinded paths - err = g.ForEachNodeChannel(node, + err = g.ForEachNodeDirectedChannel(node, func(channel *graphdb.DirectedChannel) error { // Keep track of how many incoming channels this node // has. We only use a node as an introduction node if it diff --git a/routing/unified_edges.go b/routing/unified_edges.go index b92010da0..a18547485 100644 --- a/routing/unified_edges.go +++ b/routing/unified_edges.go @@ -125,7 +125,7 @@ func (u *nodeEdgeUnifier) addGraphPolicies(g Graph) error { } // Iterate over all channels of the to node. - return g.ForEachNodeChannel(u.toNode, cb) + return g.ForEachNodeDirectedChannel(u.toNode, cb) } // unifiedEdge is the individual channel data that is kept inside an edgeUnifier