multi: reset for ForEachNodeDirectedChannel

This commit is contained in:
Elle Mouton committed 2025-07-15 11:25:10 +02:00
1 parent 13d0bd5ef6
commit 83f6dc4983
10 files changed
+62 -29

No files matched your search

+2 -2
View File
@@ -205,13 +205,13 @@ func (c *ChannelGraph) populateCache(ctx context.Context) error {
//
// NOTE: this is part of the graphdb.NodeTraverser interface.
func (c *ChannelGraph) ForEachNodeDirectedChannel(node route.Vertex,
cb func(channel *DirectedChannel) error) error {
cb func(channel *DirectedChannel) error, reset func()) error {
if c.graphCache != nil {
return c.graphCache.ForEachChannel(node, cb)
}
return c.V1Store.ForEachNodeDirectedChannel(node, cb)
return c.V1Store.ForEachNodeDirectedChannel(node, cb, reset)
}
// FetchNodeFeatures returns the features of the given node. If no features are
+3 -3
View File
@@ -1490,7 +1490,7 @@ func TestGraphTraversalCacheable(t *testing.T) {
node, func(d *DirectedChannel) error {
delete(chanIndex, d.ChannelID)
return nil
},
}, func() {},
)
require.NoError(t, err)
@@ -1499,7 +1499,7 @@ func TestGraphTraversalCacheable(t *testing.T) {
node, func(d *DirectedChannel) error {
delete(chanIndex2, d.ChannelID)
return nil
},
}, func() {},
)
require.NoError(t, err)
}
@@ -4298,7 +4298,7 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
ch = c
return nil
},
}, func() {},
)
require.NoError(t, err)
+1 -1
View File
@@ -40,7 +40,7 @@ type NodeTraverser interface {
// ForEachNodeDirectedChannel calls the callback for every channel of
// the given node.
ForEachNodeDirectedChannel(nodePub route.Vertex,
cb func(channel *DirectedChannel) error) error
cb func(channel *DirectedChannel) error, reset func()) error
// FetchNodeFeatures returns the features of the given node.
FetchNodeFeatures(nodePub route.Vertex) (*lnwire.FeatureVector, error)
+2 -4
View File
@@ -655,9 +655,7 @@ func (c *KVStore) fetchNodeFeatures(tx kvdb.RTx,
//
// NOTE: this is part of the graphdb.NodeTraverser interface.
func (c *KVStore) ForEachNodeDirectedChannel(nodePub route.Vertex,
cb func(channel *DirectedChannel) error) error {
reset := func() {}
cb func(channel *DirectedChannel) error, reset func()) error {
return c.forEachNodeDirectedChannel(nil, nodePub, cb, reset)
}
@@ -3999,7 +3997,7 @@ type nodeTraverserSession struct {
//
// NOTE: Part of the NodeTraverser interface.
func (c *nodeTraverserSession) ForEachNodeDirectedChannel(nodePub route.Vertex,
cb func(channel *DirectedChannel) error) error {
cb func(channel *DirectedChannel) error, _ func()) error {
return c.db.forEachNodeDirectedChannel(c.tx, nodePub, cb, func() {})
}
+2 -3
View File
@@ -907,9 +907,8 @@ func (s *sqlGraphNodeTx) FetchNode(nodePub route.Vertex) (NodeRTx, error) {
//
// NOTE: this is part of the graphdb.NodeTraverser interface.
func (s *SQLStore) ForEachNodeDirectedChannel(nodePub route.Vertex,
cb func(channel *DirectedChannel) error) error {
cb func(channel *DirectedChannel) error, reset func()) error {
reset := func() {}
var ctx = context.TODO()
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
@@ -2792,7 +2791,7 @@ func newSQLNodeTraverser(db SQLQueries,
//
// NOTE: Part of the NodeTraverser interface.
func (s *sqlNodeTraverser) ForEachNodeDirectedChannel(nodePub route.Vertex,
cb func(channel *DirectedChannel) error) error {
cb func(channel *DirectedChannel) error, _ func()) error {
ctx := context.TODO()