Skip to content

Commit 14f6f26

Browse files
committed
staticaddr: lock mutex for active deposits access
1 parent 34bcf1a commit 14f6f26

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

looprpc/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/lightninglabs/loop/looprpc
22

3-
go 1.22.3
3+
go 1.23.0
4+
45
toolchain go1.23.7
56

67
require (

staticaddr/deposit/manager.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func (m *Manager) Run(ctx context.Context) error {
131131
select {
132132
case height := <-newBlockChan:
133133
// Inform all active deposits about a new block arrival.
134+
m.mu.Lock()
134135
for _, fsm := range m.activeDeposits {
135136
select {
136137
case fsm.blockNtfnChan <- uint32(height):
@@ -139,11 +140,14 @@ func (m *Manager) Run(ctx context.Context) error {
139140
return ctx.Err()
140141
}
141142
}
143+
m.mu.Unlock()
142144
case outpoint := <-m.finalizedDepositChan:
143145
// If deposits notify us about their finalization, we
144146
// update the manager's internal state and flush the
145147
// finalized deposit from memory.
148+
m.mu.Lock()
146149
delete(m.activeDeposits, outpoint)
150+
m.mu.Unlock()
147151

148152
case err = <-newBlockErrChan:
149153
return err
@@ -192,7 +196,9 @@ func (m *Manager) recoverDeposits(ctx context.Context) error {
192196
}
193197
}()
194198

199+
m.mu.Lock()
195200
m.activeDeposits[d.OutPoint] = fsm
201+
m.mu.Unlock()
196202
}
197203

198204
return nil

0 commit comments

Comments
 (0)