mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
graph/db: unexport methods that take a transaction
Unexport and rename the methods that were previously used by the graphsession package.
This commit is contained in:
parent
e004447da6
commit
f3805002ff
3 changed files with 16 additions and 17 deletions
|
@ -248,13 +248,16 @@ The underlying functionality between those two options remain the same.
|
||||||
* Graph abstraction work:
|
* Graph abstraction work:
|
||||||
- [Abstract autopilot access](https://github.com/lightningnetwork/lnd/pull/9480)
|
- [Abstract autopilot access](https://github.com/lightningnetwork/lnd/pull/9480)
|
||||||
- [Abstract invoicerpc server access](https://github.com/lightningnetwork/lnd/pull/9516)
|
- [Abstract invoicerpc server access](https://github.com/lightningnetwork/lnd/pull/9516)
|
||||||
|
- [Refactor to hide DB transactions](https://github.com/lightningnetwork/lnd/pull/9513)
|
||||||
|
|
||||||
|
* [Golang was updated to
|
||||||
|
`v1.22.11`](https://github.com/lightningnetwork/lnd/pull/9462).
|
||||||
|
|
||||||
* Move funding transaction validation to the gossiper
|
* Move funding transaction validation to the gossiper
|
||||||
[1](https://github.com/lightningnetwork/lnd/pull/9476)
|
[1](https://github.com/lightningnetwork/lnd/pull/9476)
|
||||||
[2](https://github.com/lightningnetwork/lnd/pull/9477)
|
[2](https://github.com/lightningnetwork/lnd/pull/9477)
|
||||||
[3](https://github.com/lightningnetwork/lnd/pull/9478).
|
[3](https://github.com/lightningnetwork/lnd/pull/9478).
|
||||||
|
|
||||||
|
|
||||||
## Breaking Changes
|
## Breaking Changes
|
||||||
## Performance Improvements
|
## Performance Improvements
|
||||||
|
|
||||||
|
|
|
@ -490,16 +490,14 @@ func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo,
|
||||||
}, func() {})
|
}, func() {})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForEachNodeDirectedChannelTx iterates through all channels of a given node,
|
// forEachNodeDirectedChannel iterates through all channels of a given node,
|
||||||
// executing the passed callback on the directed edge representing the channel
|
// executing the passed callback on the directed edge representing the channel
|
||||||
// and its incoming policy. If the callback returns an error, then the iteration
|
// 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
|
// is halted with the error propagated back up to the caller. An optional read
|
||||||
// transaction may be provided. If none is provided, a new one will be created.
|
// transaction may be provided. If none is provided, a new one will be created.
|
||||||
//
|
//
|
||||||
// Unknown policies are passed into the callback as nil values.
|
// Unknown policies are passed into the callback as nil values.
|
||||||
//
|
func (c *ChannelGraph) forEachNodeDirectedChannel(tx kvdb.RTx,
|
||||||
// NOTE: this is part of the graphsession.graph interface.
|
|
||||||
func (c *ChannelGraph) ForEachNodeDirectedChannelTx(tx kvdb.RTx,
|
|
||||||
node route.Vertex, cb func(channel *DirectedChannel) error) error {
|
node route.Vertex, cb func(channel *DirectedChannel) error) error {
|
||||||
|
|
||||||
if c.graphCache != nil {
|
if c.graphCache != nil {
|
||||||
|
@ -510,7 +508,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannelTx(tx kvdb.RTx,
|
||||||
toNodeCallback := func() route.Vertex {
|
toNodeCallback := func() route.Vertex {
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
toNodeFeatures, err := c.FetchNodeFeaturesTx(tx, node)
|
toNodeFeatures, err := c.fetchNodeFeatures(tx, node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -554,12 +552,10 @@ func (c *ChannelGraph) ForEachNodeDirectedChannelTx(tx kvdb.RTx,
|
||||||
return nodeTraversal(tx, node[:], c.db, dbCallback)
|
return nodeTraversal(tx, node[:], c.db, dbCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchNodeFeaturesTx returns the features of a given node. If no features are
|
// fetchNodeFeatures returns the features of a given node. If no features are
|
||||||
// known for the node, an empty feature vector is returned. An optional read
|
// 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.
|
// transaction may be provided. If none is provided, a new one will be created.
|
||||||
//
|
func (c *ChannelGraph) fetchNodeFeatures(tx kvdb.RTx,
|
||||||
// NOTE: this is part of the graphsession.graph interface.
|
|
||||||
func (c *ChannelGraph) FetchNodeFeaturesTx(tx kvdb.RTx,
|
|
||||||
node route.Vertex) (*lnwire.FeatureVector, error) {
|
node route.Vertex) (*lnwire.FeatureVector, error) {
|
||||||
|
|
||||||
if c.graphCache != nil {
|
if c.graphCache != nil {
|
||||||
|
@ -597,7 +593,7 @@ func (c *ChannelGraph) FetchNodeFeaturesTx(tx kvdb.RTx,
|
||||||
func (c *ChannelGraph) ForEachNodeDirectedChannel(nodePub route.Vertex,
|
func (c *ChannelGraph) ForEachNodeDirectedChannel(nodePub route.Vertex,
|
||||||
cb func(channel *DirectedChannel) error) error {
|
cb func(channel *DirectedChannel) error) error {
|
||||||
|
|
||||||
return c.ForEachNodeDirectedChannelTx(nil, nodePub, cb)
|
return c.forEachNodeDirectedChannel(nil, nodePub, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchNodeFeatures returns the features of the given node. If no features are
|
// FetchNodeFeatures returns the features of the given node. If no features are
|
||||||
|
@ -609,7 +605,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(nodePub route.Vertex,
|
||||||
func (c *ChannelGraph) FetchNodeFeatures(nodePub route.Vertex) (
|
func (c *ChannelGraph) FetchNodeFeatures(nodePub route.Vertex) (
|
||||||
*lnwire.FeatureVector, error) {
|
*lnwire.FeatureVector, error) {
|
||||||
|
|
||||||
return c.FetchNodeFeaturesTx(nil, nodePub)
|
return c.fetchNodeFeatures(nil, nodePub)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForEachNodeCached is similar to forEachNode, but it utilizes the channel
|
// ForEachNodeCached is similar to forEachNode, but it utilizes the channel
|
||||||
|
@ -641,7 +637,7 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
|
||||||
toNodeCallback := func() route.Vertex {
|
toNodeCallback := func() route.Vertex {
|
||||||
return node.PubKeyBytes
|
return node.PubKeyBytes
|
||||||
}
|
}
|
||||||
toNodeFeatures, err := c.FetchNodeFeaturesTx(
|
toNodeFeatures, err := c.fetchNodeFeatures(
|
||||||
tx, node.PubKeyBytes,
|
tx, node.PubKeyBytes,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3942,7 +3938,7 @@ type nodeTraverserSession struct {
|
||||||
func (c *nodeTraverserSession) ForEachNodeDirectedChannel(nodePub route.Vertex,
|
func (c *nodeTraverserSession) ForEachNodeDirectedChannel(nodePub route.Vertex,
|
||||||
cb func(channel *DirectedChannel) error) error {
|
cb func(channel *DirectedChannel) error) error {
|
||||||
|
|
||||||
return c.db.ForEachNodeDirectedChannelTx(c.tx, nodePub, cb)
|
return c.db.forEachNodeDirectedChannel(c.tx, nodePub, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchNodeFeatures returns the features of the given node. If the node is
|
// FetchNodeFeatures returns the features of the given node. If the node is
|
||||||
|
@ -3952,7 +3948,7 @@ func (c *nodeTraverserSession) ForEachNodeDirectedChannel(nodePub route.Vertex,
|
||||||
func (c *nodeTraverserSession) FetchNodeFeatures(nodePub route.Vertex) (
|
func (c *nodeTraverserSession) FetchNodeFeatures(nodePub route.Vertex) (
|
||||||
*lnwire.FeatureVector, error) {
|
*lnwire.FeatureVector, error) {
|
||||||
|
|
||||||
return c.db.FetchNodeFeaturesTx(c.tx, nodePub)
|
return c.db.fetchNodeFeatures(c.tx, nodePub)
|
||||||
}
|
}
|
||||||
|
|
||||||
func putLightningNode(nodeBucket kvdb.RwBucket, aliasBucket kvdb.RwBucket, // nolint:dupl
|
func putLightningNode(nodeBucket kvdb.RwBucket, aliasBucket kvdb.RwBucket, // nolint:dupl
|
||||||
|
|
|
@ -3915,7 +3915,7 @@ func BenchmarkForEachChannel(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestGraphCacheForEachNodeChannel tests that the ForEachNodeDirectedChannelTx
|
// TestGraphCacheForEachNodeChannel tests that the forEachNodeDirectedChannel
|
||||||
// method works as expected, and is able to handle nil self edges.
|
// method works as expected, and is able to handle nil self edges.
|
||||||
func TestGraphCacheForEachNodeChannel(t *testing.T) {
|
func TestGraphCacheForEachNodeChannel(t *testing.T) {
|
||||||
graph, err := MakeTestGraph(t)
|
graph, err := MakeTestGraph(t)
|
||||||
|
@ -3952,7 +3952,7 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
|
||||||
|
|
||||||
getSingleChannel := func() *DirectedChannel {
|
getSingleChannel := func() *DirectedChannel {
|
||||||
var ch *DirectedChannel
|
var ch *DirectedChannel
|
||||||
err = graph.ForEachNodeDirectedChannelTx(nil, node1.PubKeyBytes,
|
err = graph.forEachNodeDirectedChannel(nil, node1.PubKeyBytes,
|
||||||
func(c *DirectedChannel) error {
|
func(c *DirectedChannel) error {
|
||||||
require.Nil(t, ch)
|
require.Nil(t, ch)
|
||||||
ch = c
|
ch = c
|
||||||
|
|
Loading…
Add table
Reference in a new issue