diff --git a/graph/db/graph.go b/graph/db/graph.go index a7d3cf299..49c24441b 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -500,7 +500,7 @@ func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo, }, func() {}) } -// ForEachNodeDirectedChannel iterates through all channels of a given node, +// ForEachNodeDirectedChannelTx iterates through all channels of a given node, // executing the passed callback on the directed edge representing the channel // and its incoming policy. If the callback returns an error, then the iteration // is halted with the error propagated back up to the caller. An optional read @@ -509,7 +509,7 @@ func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo, // Unknown policies are passed into the callback as nil values. // // NOTE: this is part of the graphsession.graph interface. -func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx, +func (c *ChannelGraph) ForEachNodeDirectedChannelTx(tx kvdb.RTx, node route.Vertex, cb func(channel *DirectedChannel) error) error { if c.graphCache != nil { @@ -520,7 +520,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx, toNodeCallback := func() route.Vertex { return node } - toNodeFeatures, err := c.FetchNodeFeatures(tx, node) + toNodeFeatures, err := c.FetchNodeFeaturesTx(tx, node) if err != nil { return err } @@ -564,12 +564,12 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx, return nodeTraversal(tx, node[:], c.db, dbCallback) } -// FetchNodeFeatures returns the features of a given node. If no features are +// FetchNodeFeaturesTx returns the features of a given node. If no features are // known for the node, an empty feature vector is returned. An optional read // transaction may be provided. If none is provided, a new one will be created. // // NOTE: this is part of the graphsession.graph interface. -func (c *ChannelGraph) FetchNodeFeatures(tx kvdb.RTx, +func (c *ChannelGraph) FetchNodeFeaturesTx(tx kvdb.RTx, node route.Vertex) (*lnwire.FeatureVector, error) { if c.graphCache != nil { @@ -623,7 +623,7 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex, toNodeCallback := func() route.Vertex { return node.PubKeyBytes } - toNodeFeatures, err := c.FetchNodeFeatures( + toNodeFeatures, err := c.FetchNodeFeaturesTx( tx, node.PubKeyBytes, ) if err != nil { diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index eb658e2f1..b4731fbd8 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -3915,7 +3915,7 @@ func BenchmarkForEachChannel(b *testing.B) { } } -// TestGraphCacheForEachNodeChannel tests that the ForEachNodeDirectedChannel +// TestGraphCacheForEachNodeChannel tests that the ForEachNodeDirectedChannelTx // method works as expected, and is able to handle nil self edges. func TestGraphCacheForEachNodeChannel(t *testing.T) { graph, err := MakeTestGraph(t) @@ -3952,7 +3952,7 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) { getSingleChannel := func() *DirectedChannel { var ch *DirectedChannel - err = graph.ForEachNodeDirectedChannel(nil, node1.PubKeyBytes, + err = graph.ForEachNodeDirectedChannelTx(nil, node1.PubKeyBytes, func(c *DirectedChannel) error { require.Nil(t, ch) ch = c diff --git a/graph/graphsession/graph_session.go b/graph/graphsession/graph_session.go index c555e4b1a..786303d2e 100644 --- a/graph/graphsession/graph_session.go +++ b/graph/graphsession/graph_session.go @@ -86,7 +86,7 @@ func (g *session) close() error { func (g *session) ForEachNodeChannel(nodePub route.Vertex, cb func(channel *graphdb.DirectedChannel) error) error { - return g.graph.ForEachNodeDirectedChannel(g.tx, nodePub, cb) + return g.graph.ForEachNodeDirectedChannelTx(g.tx, nodePub, cb) } // FetchNodeFeatures returns the features of the given node. If the node is @@ -96,7 +96,7 @@ func (g *session) ForEachNodeChannel(nodePub route.Vertex, func (g *session) FetchNodeFeatures(nodePub route.Vertex) ( *lnwire.FeatureVector, error) { - return g.graph.FetchNodeFeatures(g.tx, nodePub) + return g.graph.FetchNodeFeaturesTx(g.tx, nodePub) } // A compile-time check to ensure that *session implements the @@ -118,7 +118,7 @@ type ReadOnlyGraph interface { // database implementation, like channeldb.ChannelGraph, in order to be used by // the Router for pathfinding. type graph interface { - // ForEachNodeDirectedChannel iterates through all channels of a given + // ForEachNodeDirectedChannelTx iterates through all channels of a given // node, executing the passed callback on the directed edge representing // the channel and its incoming policy. If the callback returns an // error, then the iteration is halted with the error propagated back @@ -128,15 +128,15 @@ type graph interface { // // NOTE: if a nil tx is provided, then it is expected that the // implementation create a read only tx. - ForEachNodeDirectedChannel(tx kvdb.RTx, node route.Vertex, + ForEachNodeDirectedChannelTx(tx kvdb.RTx, node route.Vertex, cb func(channel *graphdb.DirectedChannel) error) error - // FetchNodeFeatures returns the features of a given node. If no + // FetchNodeFeaturesTx returns the features of a given node. If no // features are known for the node, an empty feature vector is returned. // // NOTE: if a nil tx is provided, then it is expected that the // implementation create a read only tx. - FetchNodeFeatures(tx kvdb.RTx, node route.Vertex) ( + FetchNodeFeaturesTx(tx kvdb.RTx, node route.Vertex) ( *lnwire.FeatureVector, error) } diff --git a/routing/integrated_routing_context_test.go b/routing/integrated_routing_context_test.go index 5acae868d..c11b055d9 100644 --- a/routing/integrated_routing_context_test.go +++ b/routing/integrated_routing_context_test.go @@ -394,11 +394,11 @@ func (g *mockGraphSessionChanDB) close() error { func (g *mockGraphSessionChanDB) ForEachNodeChannel(nodePub route.Vertex, cb func(channel *graphdb.DirectedChannel) error) error { - return g.graph.ForEachNodeDirectedChannel(g.tx, nodePub, cb) + return g.graph.ForEachNodeDirectedChannelTx(g.tx, nodePub, cb) } func (g *mockGraphSessionChanDB) FetchNodeFeatures(nodePub route.Vertex) ( *lnwire.FeatureVector, error) { - return g.graph.FetchNodeFeatures(g.tx, nodePub) + return g.graph.FetchNodeFeaturesTx(g.tx, nodePub) }