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:
@@ -50,20 +50,17 @@ func NewSimpleGraph(ctx context.Context, g ChannelGraph) (*SimpleGraph, error) {
|
||||
|
||||
// Iterate over each node and each channel and update the adj and the
|
||||
// node index.
|
||||
err := g.ForEachNode(ctx, func(ctx context.Context, node Node) error {
|
||||
err := g.ForEachNodesChannels(ctx, func(_ context.Context,
|
||||
node Node, channels []*ChannelEdge) error {
|
||||
|
||||
u := getNodeIndex(node.PubKey())
|
||||
|
||||
return node.ForEachChannel(
|
||||
ctx, func(_ context.Context,
|
||||
edge ChannelEdge) error {
|
||||
for _, edge := range channels {
|
||||
v := getNodeIndex(edge.Peer)
|
||||
adj[u] = append(adj[u], v)
|
||||
}
|
||||
|
||||
v := getNodeIndex(edge.Peer)
|
||||
|
||||
adj[u] = append(adj[u], v)
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
return nil
|
||||
}, func() {
|
||||
clear(adj)
|
||||
clear(nodes)
|
||||
|
Reference in New Issue
Block a user