Skip to content

Commit f380500

Browse files
committed
graph/db: unexport methods that take a transaction
Unexport and rename the methods that were previously used by the graphsession package.
1 parent e004447 commit f380500

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

docs/release-notes/release-notes-0.19.0.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,16 @@ The underlying functionality between those two options remain the same.
248248
* Graph abstraction work:
249249
- [Abstract autopilot access](https://github.com/lightningnetwork/lnd/pull/9480)
250250
- [Abstract invoicerpc server access](https://github.com/lightningnetwork/lnd/pull/9516)
251+
- [Refactor to hide DB transactions](https://github.com/lightningnetwork/lnd/pull/9513)
252+
253+
* [Golang was updated to
254+
`v1.22.11`](https://github.com/lightningnetwork/lnd/pull/9462).
251255

252256
* Move funding transaction validation to the gossiper
253257
[1](https://github.com/lightningnetwork/lnd/pull/9476)
254258
[2](https://github.com/lightningnetwork/lnd/pull/9477)
255259
[3](https://github.com/lightningnetwork/lnd/pull/9478).
256260

257-
258261
## Breaking Changes
259262
## Performance Improvements
260263

graph/db/graph.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -490,16 +490,14 @@ func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo,
490490
}, func() {})
491491
}
492492

493-
// ForEachNodeDirectedChannelTx iterates through all channels of a given node,
493+
// forEachNodeDirectedChannel iterates through all channels of a given node,
494494
// executing the passed callback on the directed edge representing the channel
495495
// and its incoming policy. If the callback returns an error, then the iteration
496496
// is halted with the error propagated back up to the caller. An optional read
497497
// transaction may be provided. If none is provided, a new one will be created.
498498
//
499499
// Unknown policies are passed into the callback as nil values.
500-
//
501-
// NOTE: this is part of the graphsession.graph interface.
502-
func (c *ChannelGraph) ForEachNodeDirectedChannelTx(tx kvdb.RTx,
500+
func (c *ChannelGraph) forEachNodeDirectedChannel(tx kvdb.RTx,
503501
node route.Vertex, cb func(channel *DirectedChannel) error) error {
504502

505503
if c.graphCache != nil {
@@ -510,7 +508,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannelTx(tx kvdb.RTx,
510508
toNodeCallback := func() route.Vertex {
511509
return node
512510
}
513-
toNodeFeatures, err := c.FetchNodeFeaturesTx(tx, node)
511+
toNodeFeatures, err := c.fetchNodeFeatures(tx, node)
514512
if err != nil {
515513
return err
516514
}
@@ -554,12 +552,10 @@ func (c *ChannelGraph) ForEachNodeDirectedChannelTx(tx kvdb.RTx,
554552
return nodeTraversal(tx, node[:], c.db, dbCallback)
555553
}
556554

557-
// FetchNodeFeaturesTx returns the features of a given node. If no features are
555+
// fetchNodeFeatures returns the features of a given node. If no features are
558556
// known for the node, an empty feature vector is returned. An optional read
559557
// transaction may be provided. If none is provided, a new one will be created.
560-
//
561-
// NOTE: this is part of the graphsession.graph interface.
562-
func (c *ChannelGraph) FetchNodeFeaturesTx(tx kvdb.RTx,
558+
func (c *ChannelGraph) fetchNodeFeatures(tx kvdb.RTx,
563559
node route.Vertex) (*lnwire.FeatureVector, error) {
564560

565561
if c.graphCache != nil {
@@ -597,7 +593,7 @@ func (c *ChannelGraph) FetchNodeFeaturesTx(tx kvdb.RTx,
597593
func (c *ChannelGraph) ForEachNodeDirectedChannel(nodePub route.Vertex,
598594
cb func(channel *DirectedChannel) error) error {
599595

600-
return c.ForEachNodeDirectedChannelTx(nil, nodePub, cb)
596+
return c.forEachNodeDirectedChannel(nil, nodePub, cb)
601597
}
602598

603599
// FetchNodeFeatures returns the features of the given node. If no features are
@@ -609,7 +605,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(nodePub route.Vertex,
609605
func (c *ChannelGraph) FetchNodeFeatures(nodePub route.Vertex) (
610606
*lnwire.FeatureVector, error) {
611607

612-
return c.FetchNodeFeaturesTx(nil, nodePub)
608+
return c.fetchNodeFeatures(nil, nodePub)
613609
}
614610

615611
// ForEachNodeCached is similar to forEachNode, but it utilizes the channel
@@ -641,7 +637,7 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
641637
toNodeCallback := func() route.Vertex {
642638
return node.PubKeyBytes
643639
}
644-
toNodeFeatures, err := c.FetchNodeFeaturesTx(
640+
toNodeFeatures, err := c.fetchNodeFeatures(
645641
tx, node.PubKeyBytes,
646642
)
647643
if err != nil {
@@ -3942,7 +3938,7 @@ type nodeTraverserSession struct {
39423938
func (c *nodeTraverserSession) ForEachNodeDirectedChannel(nodePub route.Vertex,
39433939
cb func(channel *DirectedChannel) error) error {
39443940

3945-
return c.db.ForEachNodeDirectedChannelTx(c.tx, nodePub, cb)
3941+
return c.db.forEachNodeDirectedChannel(c.tx, nodePub, cb)
39463942
}
39473943

39483944
// FetchNodeFeatures returns the features of the given node. If the node is
@@ -3952,7 +3948,7 @@ func (c *nodeTraverserSession) ForEachNodeDirectedChannel(nodePub route.Vertex,
39523948
func (c *nodeTraverserSession) FetchNodeFeatures(nodePub route.Vertex) (
39533949
*lnwire.FeatureVector, error) {
39543950

3955-
return c.db.FetchNodeFeaturesTx(c.tx, nodePub)
3951+
return c.db.fetchNodeFeatures(c.tx, nodePub)
39563952
}
39573953

39583954
func putLightningNode(nodeBucket kvdb.RwBucket, aliasBucket kvdb.RwBucket, // nolint:dupl

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 ForEachNodeDirectedChannelTx
3918+
// TestGraphCacheForEachNodeChannel tests that the forEachNodeDirectedChannel
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.ForEachNodeDirectedChannelTx(nil, node1.PubKeyBytes,
3955+
err = graph.forEachNodeDirectedChannel(nil, node1.PubKeyBytes,
39563956
func(c *DirectedChannel) error {
39573957
require.Nil(t, ch)
39583958
ch = c

0 commit comments

Comments
 (0)