multi: add reset to ForEachNode

This commit is contained in:
Elle Mouton committed 2025-07-15 11:25:09 +02:00
1 parent c32bf642d2
commit 21ac7ef6f4
9 files changed
+17 -13

No files matched your search

+3 -3
View File
@@ -1454,7 +1454,7 @@ func TestGraphTraversalCacheable(t *testing.T) {
nodeMap[tx.Node().PubKeyBytes] = struct{}{}
return nil
})
}, func() {})
require.NoError(t, err)
require.Len(t, nodeMap, numNodes)
@@ -1583,7 +1583,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
err := graph.ForEachNode(ctx, func(tx NodeRTx) error {
delete(nodeIndex, tx.Node().Alias)
return nil
})
}, func() {})
require.NoError(t, err)
require.Len(t, nodeIndex, 0)
@@ -1693,7 +1693,7 @@ func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
numNodes++
return nil
})
}, func() {})
if err != nil {
_, _, line, _ := runtime.Caller(1)
t.Fatalf("line %v: unable to scan nodes: %v", line, err)
+2 -1
View File
@@ -102,7 +102,8 @@ type V1Store interface { //nolint:interfacebloat
// passed to the call-back are executed under the same read transaction
// and so, methods on the NodeTx object _MUST_ only be called from
// within the call-back.
ForEachNode(ctx context.Context, cb func(tx NodeRTx) error) error
ForEachNode(ctx context.Context, cb func(tx NodeRTx) error,
reset func()) error
// ForEachNodeCacheable iterates through all the stored vertices/nodes
// in the graph, executing the passed callback with each node
+1 -3
View File
@@ -802,9 +802,7 @@ func (c *KVStore) DisabledChannelIDs() ([]uint64, error) {
// executed under the same read transaction and so, methods on the NodeTx object
// _MUST_ only be called from within the call-back.
func (c *KVStore) ForEachNode(_ context.Context,
cb func(tx NodeRTx) error) error {
reset := func() {}
cb func(tx NodeRTx) error, reset func()) error {
return forEachNode(c.db, func(tx kvdb.RTx,
node *models.LightningNode) error {
+2
View File
@@ -401,6 +401,8 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
nodes = append(nodes, node)
return nil
}, func() {
nodes = nil
})
require.NoError(t, err)
+1 -3
View File
@@ -785,9 +785,7 @@ func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
//
// NOTE: part of the V1Store interface.
func (s *SQLStore) ForEachNode(ctx context.Context,
cb func(tx NodeRTx) error) error {
reset := func() {}
cb func(tx NodeRTx) error, reset func()) error {
var lastID int64 = 0
handleNode := func(db SQLQueries, dbNode sqlc.Node) error {