From a5cf958c2c5a7e3c8e3364c6a63c9b5c8fcd9041 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Thu, 18 Sep 2025 07:37:53 +0200 Subject: [PATCH] autopilot: fix nil map assignment Use the `clear` call to reset a map on `reset` instead of assigning nil to the entry. --- autopilot/agent.go | 4 ++-- discovery/bootstrapper.go | 2 +- rpcserver.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/autopilot/agent.go b/autopilot/agent.go index ffb3d38fe..cbb29f38c 100644 --- a/autopilot/agent.go +++ b/autopilot/agent.go @@ -644,8 +644,8 @@ func (a *Agent) openChans(ctx context.Context, availableFunds btcutil.Amount, nodes[nID] = struct{}{} return nil }, func() { - nodes = nil - addresses = nil + clear(nodes) + clear(addresses) }); err != nil { return fmt.Errorf("unable to get graph nodes: %w", err) } diff --git a/discovery/bootstrapper.go b/discovery/bootstrapper.go index 1b6c981d4..43e9d5ec2 100644 --- a/discovery/bootstrapper.go +++ b/discovery/bootstrapper.go @@ -249,7 +249,7 @@ func (c *ChannelGraphBootstrapper) SampleNodeAddrs(_ context.Context, return errFound }, func() { - a = nil + clear(a) }) if err != nil && !errors.Is(err, errFound) { return nil, err diff --git a/rpcserver.go b/rpcserver.go index 75a24720a..96dee318b 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -7284,7 +7284,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context, totalNetworkCapacity = 0 minChannelSize = math.MaxInt64 maxChannelSize = 0 - allChans = nil + clear(allChans) clear(seenChans) }) if err != nil {