autopilot: remove the ForEachChannel method from Node interface

And instead make use of the new ForEachNodesChannels method which
uses a much more efficient method for iterating through nodes&channels.
This commit is contained in:
Elle Mouton committed 2025-08-06 09:52:09 +02:00
1 parent ce7fe84da7
commit 699e335954
5 files changed
+82 -168

No files matched your search

+10 -12
View File
@@ -242,25 +242,23 @@ func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) {
numNodes := 0
twoChans := false
nodes := make(map[NodeID]struct{})
err = graph.ForEachNode(
ctx, func(ctx context.Context, n Node) error {
err = graph.ForEachNodesChannels(
ctx, func(_ context.Context, node Node,
edges []*ChannelEdge) error {
numNodes++
nodes[n.PubKey()] = struct{}{}
nodes[node.PubKey()] = struct{}{}
numChans := 0
err := n.ForEachChannel(ctx,
func(_ context.Context, c ChannelEdge) error { //nolint:ll
numChans++
return nil
},
)
if err != nil {
return err
for range edges {
numChans++
}
twoChans = twoChans || (numChans == 2)
return nil
}, func() {
},
func() {
numNodes = 0
twoChans = false
clear(nodes)