mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user