multi: pass reset to ForEachNodeCached

This commit is contained in:
Elle Mouton committed 2025-07-15 11:23:27 +02:00
1 parent e5fbca8299
commit c32bf642d2
14 files changed
+61 -25

No files matched your search

+3 -3
View File
@@ -246,14 +246,14 @@ func (c *ChannelGraph) GraphSession(cb func(graph NodeTraverser) error) error {
//
// NOTE: The callback contents MUST not be modified.
func (c *ChannelGraph) ForEachNodeCached(ctx context.Context,
cb func(node route.Vertex,
chans map[uint64]*DirectedChannel) error) error {
cb func(node route.Vertex, chans map[uint64]*DirectedChannel) error,
reset func()) error {
if c.graphCache != nil {
return c.graphCache.ForEachNode(cb)
}
return c.V1Store.ForEachNodeCached(ctx, cb)
return c.V1Store.ForEachNodeCached(ctx, cb, reset)
}
// AddLightningNode adds a vertex/node to the graph database. If the node is not
+1 -1
View File
@@ -1374,7 +1374,7 @@ func TestGraphTraversal(t *testing.T) {
}
return nil
})
}, func() {})
require.NoError(t, err)
// Iterate through all the known channels within the graph DB, once
+1 -1
View File
@@ -93,7 +93,7 @@ type V1Store interface { //nolint:interfacebloat
//
// NOTE: The callback contents MUST not be modified.
ForEachNodeCached(ctx context.Context, cb func(node route.Vertex,
chans map[uint64]*DirectedChannel) error) error
chans map[uint64]*DirectedChannel) error, reset func()) error
// ForEachNode iterates through all the stored vertices/nodes in the
// graph, executing the passed callback with each node encountered. If
+2 -4
View File
@@ -678,10 +678,8 @@ func (c *KVStore) FetchNodeFeatures(nodePub route.Vertex) (
//
// NOTE: The callback contents MUST not be modified.
func (c *KVStore) ForEachNodeCached(_ context.Context,
cb func(node route.Vertex,
chans map[uint64]*DirectedChannel) error) error {
reset := func() {}
cb func(node route.Vertex, chans map[uint64]*DirectedChannel) error,
reset func()) error {
// Otherwise call back to a version that uses the database directly.
// We'll iterate over each node, then the set of channels for each
+2 -4
View File
@@ -1109,10 +1109,8 @@ func (s *SQLStore) ChanUpdatesInHorizon(startTime,
//
// NOTE: part of the V1Store interface.
func (s *SQLStore) ForEachNodeCached(ctx context.Context,
cb func(node route.Vertex,
chans map[uint64]*DirectedChannel) error) error {
reset := func() {}
cb func(node route.Vertex, chans map[uint64]*DirectedChannel) error,
reset func()) error {
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
return forEachNodeCacheable(ctx, db, func(nodeID int64,