Skip to content

Commit 971832c

Browse files
committed
graph: temporarily rename some ChannelGraph methods
Add the `Tx` suffix to both ForEachNodeDirectedChannelTx and FetchNodeFeatures temporarily so that we free up the original names for other use. The renamed methods will be removed or unexported in an upcoming commit. The aim is to have no exported methods on the ChannelGraph that accept a kvdb.RTx as a parameter.
1 parent 9068ffc commit 971832c

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

graph/db/graph.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo,
500500
}, func() {})
501501
}
502502

503-
// ForEachNodeDirectedChannel iterates through all channels of a given node,
503+
// ForEachNodeDirectedChannelTx iterates through all channels of a given node,
504504
// executing the passed callback on the directed edge representing the channel
505505
// and its incoming policy. If the callback returns an error, then the iteration
506506
// 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,
509509
// Unknown policies are passed into the callback as nil values.
510510
//
511511
// NOTE: this is part of the graphsession.graph interface.
512-
func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx,
512+
func (c *ChannelGraph) ForEachNodeDirectedChannelTx(tx kvdb.RTx,
513513
node route.Vertex, cb func(channel *DirectedChannel) error) error {
514514

515515
if c.graphCache != nil {
@@ -520,7 +520,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx,
520520
toNodeCallback := func() route.Vertex {
521521
return node
522522
}
523-
toNodeFeatures, err := c.FetchNodeFeatures(tx, node)
523+
toNodeFeatures, err := c.FetchNodeFeaturesTx(tx, node)
524524
if err != nil {
525525
return err
526526
}
@@ -564,12 +564,12 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx,
564564
return nodeTraversal(tx, node[:], c.db, dbCallback)
565565
}
566566

567-
// FetchNodeFeatures returns the features of a given node. If no features are
567+
// FetchNodeFeaturesTx returns the features of a given node. If no features are
568568
// known for the node, an empty feature vector is returned. An optional read
569569
// transaction may be provided. If none is provided, a new one will be created.
570570
//
571571
// NOTE: this is part of the graphsession.graph interface.
572-
func (c *ChannelGraph) FetchNodeFeatures(tx kvdb.RTx,
572+
func (c *ChannelGraph) FetchNodeFeaturesTx(tx kvdb.RTx,
573573
node route.Vertex) (*lnwire.FeatureVector, error) {
574574

575575
if c.graphCache != nil {
@@ -623,7 +623,7 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
623623
toNodeCallback := func() route.Vertex {
624624
return node.PubKeyBytes
625625
}
626-
toNodeFeatures, err := c.FetchNodeFeatures(
626+
toNodeFeatures, err := c.FetchNodeFeaturesTx(
627627
tx, node.PubKeyBytes,
628628
)
629629
if err != nil {

graph/db/graph_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3915,7 +3915,7 @@ func BenchmarkForEachChannel(b *testing.B) {
39153915
}
39163916
}
39173917

3918-
// TestGraphCacheForEachNodeChannel tests that the ForEachNodeDirectedChannel
3918+
// TestGraphCacheForEachNodeChannel tests that the ForEachNodeDirectedChannelTx
39193919
// method works as expected, and is able to handle nil self edges.
39203920
func TestGraphCacheForEachNodeChannel(t *testing.T) {
39213921
graph, err := MakeTestGraph(t)
@@ -3952,7 +3952,7 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
39523952

39533953
getSingleChannel := func() *DirectedChannel {
39543954
var ch *DirectedChannel
3955-
err = graph.ForEachNodeDirectedChannel(nil, node1.PubKeyBytes,
3955+
err = graph.ForEachNodeDirectedChannelTx(nil, node1.PubKeyBytes,
39563956
func(c *DirectedChannel) error {
39573957
require.Nil(t, ch)
39583958
ch = c

graph/graphsession/graph_session.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (g *session) close() error {
8686
func (g *session) ForEachNodeChannel(nodePub route.Vertex,
8787
cb func(channel *graphdb.DirectedChannel) error) error {
8888

89-
return g.graph.ForEachNodeDirectedChannel(g.tx, nodePub, cb)
89+
return g.graph.ForEachNodeDirectedChannelTx(g.tx, nodePub, cb)
9090
}
9191

9292
// FetchNodeFeatures returns the features of the given node. If the node is
@@ -96,7 +96,7 @@ func (g *session) ForEachNodeChannel(nodePub route.Vertex,
9696
func (g *session) FetchNodeFeatures(nodePub route.Vertex) (
9797
*lnwire.FeatureVector, error) {
9898

99-
return g.graph.FetchNodeFeatures(g.tx, nodePub)
99+
return g.graph.FetchNodeFeaturesTx(g.tx, nodePub)
100100
}
101101

102102
// A compile-time check to ensure that *session implements the
@@ -118,7 +118,7 @@ type ReadOnlyGraph interface {
118118
// database implementation, like channeldb.ChannelGraph, in order to be used by
119119
// the Router for pathfinding.
120120
type graph interface {
121-
// ForEachNodeDirectedChannel iterates through all channels of a given
121+
// ForEachNodeDirectedChannelTx iterates through all channels of a given
122122
// node, executing the passed callback on the directed edge representing
123123
// the channel and its incoming policy. If the callback returns an
124124
// error, then the iteration is halted with the error propagated back
@@ -128,15 +128,15 @@ type graph interface {
128128
//
129129
// NOTE: if a nil tx is provided, then it is expected that the
130130
// implementation create a read only tx.
131-
ForEachNodeDirectedChannel(tx kvdb.RTx, node route.Vertex,
131+
ForEachNodeDirectedChannelTx(tx kvdb.RTx, node route.Vertex,
132132
cb func(channel *graphdb.DirectedChannel) error) error
133133

134-
// FetchNodeFeatures returns the features of a given node. If no
134+
// FetchNodeFeaturesTx returns the features of a given node. If no
135135
// features are known for the node, an empty feature vector is returned.
136136
//
137137
// NOTE: if a nil tx is provided, then it is expected that the
138138
// implementation create a read only tx.
139-
FetchNodeFeatures(tx kvdb.RTx, node route.Vertex) (
139+
FetchNodeFeaturesTx(tx kvdb.RTx, node route.Vertex) (
140140
*lnwire.FeatureVector, error)
141141
}
142142

routing/integrated_routing_context_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,11 @@ func (g *mockGraphSessionChanDB) close() error {
394394
func (g *mockGraphSessionChanDB) ForEachNodeChannel(nodePub route.Vertex,
395395
cb func(channel *graphdb.DirectedChannel) error) error {
396396

397-
return g.graph.ForEachNodeDirectedChannel(g.tx, nodePub, cb)
397+
return g.graph.ForEachNodeDirectedChannelTx(g.tx, nodePub, cb)
398398
}
399399

400400
func (g *mockGraphSessionChanDB) FetchNodeFeatures(nodePub route.Vertex) (
401401
*lnwire.FeatureVector, error) {
402402

403-
return g.graph.FetchNodeFeatures(g.tx, nodePub)
403+
return g.graph.FetchNodeFeaturesTx(g.tx, nodePub)
404404
}

0 commit comments

Comments
 (0)