From 08cde9886916bacd8ec9376677005abb027c33c3 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 22 Mar 2023 11:35:25 +0200 Subject: [PATCH] wtclient: add mutex locking in perUpdate Lock the `backupMu` when accessing `c.chanCommitHeights` in the `New` function. It is not strictly necessary right now but good to add it so that there is no accidental oversight if the `perUpdate` method is ever extracted and reused in future. --- watchtower/wtclient/client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/watchtower/wtclient/client.go b/watchtower/wtclient/client.go index fe4b18648..8a2597980 100644 --- a/watchtower/wtclient/client.go +++ b/watchtower/wtclient/client.go @@ -386,6 +386,9 @@ func New(config *Config) (*TowerClient, error) { return } + c.backupMu.Lock() + defer c.backupMu.Unlock() + // Take the highest commit height found in the session's acked // updates. height, ok := c.chanCommitHeights[chanID]