graph/db: pass reset to ForEachNodeCacheable

This commit is contained in:
Elle Mouton committed 2025-07-15 11:25:09 +02:00
1 parent 21ac7ef6f4
commit e17fd58a1d
5 files changed
+10 -8

No files matched your search

+1 -1
View File
@@ -170,7 +170,7 @@ func (c *ChannelGraph) populateCache(ctx context.Context) error {
c.graphCache.AddNodeFeatures(node, features) c.graphCache.AddNodeFeatures(node, features)
return nil return nil
}) }, func() {})
if err != nil { if err != nil {
return err return err
} }
+4
View File
@@ -1469,6 +1469,8 @@ func TestGraphTraversalCacheable(t *testing.T) {
nodes = append(nodes, node) nodes = append(nodes, node)
return nil return nil
}, func() {
nodes = nil
}) })
require.NoError(t, err) require.NoError(t, err)
require.Len(t, nodeMap, 0) require.Len(t, nodeMap, 0)
@@ -4227,6 +4229,8 @@ func BenchmarkForEachChannel(b *testing.B) {
nodes = append(nodes, node) nodes = append(nodes, node)
return nil return nil
}, func() {
nodes = nil
}) })
require.NoError(b, err) require.NoError(b, err)
+1 -1
View File
@@ -110,7 +110,7 @@ type V1Store interface { //nolint:interfacebloat
// encountered. If the callback returns an error, then the transaction // encountered. If the callback returns an error, then the transaction
// is aborted and the iteration stops early. // is aborted and the iteration stops early.
ForEachNodeCacheable(ctx context.Context, cb func(route.Vertex, ForEachNodeCacheable(ctx context.Context, cb func(route.Vertex,
*lnwire.FeatureVector) error) error *lnwire.FeatureVector) error, reset func()) error
// LookupAlias attempts to return the alias as advertised by the target // LookupAlias attempts to return the alias as advertised by the target
// node. // node.
+2 -3
View File
@@ -857,9 +857,8 @@ func forEachNode(db kvdb.Backend,
// callback returns an error, then the transaction is aborted and the iteration // callback returns an error, then the transaction is aborted and the iteration
// stops early. // stops early.
func (c *KVStore) ForEachNodeCacheable(_ context.Context, func (c *KVStore) ForEachNodeCacheable(_ context.Context,
cb func(route.Vertex, *lnwire.FeatureVector) error) error { cb func(route.Vertex, *lnwire.FeatureVector) error,
reset func()) error {
reset := func() {}
traversal := func(tx kvdb.RTx) error { traversal := func(tx kvdb.RTx) error {
// First grab the nodes bucket which stores the mapping from // First grab the nodes bucket which stores the mapping from
+2 -3
View File
@@ -924,9 +924,8 @@ func (s *SQLStore) ForEachNodeDirectedChannel(nodePub route.Vertex,
// //
// NOTE: This is a part of the V1Store interface. // NOTE: This is a part of the V1Store interface.
func (s *SQLStore) ForEachNodeCacheable(ctx context.Context, func (s *SQLStore) ForEachNodeCacheable(ctx context.Context,
cb func(route.Vertex, *lnwire.FeatureVector) error) error { cb func(route.Vertex, *lnwire.FeatureVector) error,
reset func()) error {
reset := func() {}
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
return forEachNodeCacheable(ctx, db, func(nodeID int64, return forEachNodeCacheable(ctx, db, func(nodeID int64,