Skip to content

Commit 183c775

Browse files
committed
staticaddr: lock mutex for active deposits access
1 parent d2c08bb commit 183c775

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
@@ -136,6 +136,7 @@ func (m *Manager) Run(ctx context.Context, currentHeight uint32) error {
136136
select {
137137
case height := <-newBlockChan:
138138
// Inform all active deposits about a new block arrival.
139+
m.mu.Lock()
139140
for _, fsm := range m.activeDeposits {
140141
select {
141142
case fsm.blockNtfnChan <- uint32(height):
@@ -144,11 +145,14 @@ func (m *Manager) Run(ctx context.Context, currentHeight uint32) error {
144145
return ctx.Err()
145146
}
146147
}
148+
m.mu.Unlock()
147149
case outpoint := <-m.finalizedDepositChan:
148150
// If deposits notify us about their finalization, we
149151
// update the manager's internal state and flush the
150152
// finalized deposit from memory.
153+
m.mu.Lock()
151154
delete(m.activeDeposits, outpoint)
155+
m.mu.Unlock()
152156

153157
case err = <-newBlockErrChan:
154158
return err
@@ -197,7 +201,9 @@ func (m *Manager) recoverDeposits(ctx context.Context) error {
197201
}
198202
}()
199203

204+
m.mu.Lock()
200205
m.activeDeposits[d.OutPoint] = fsm
206+
m.mu.Unlock()
201207
}
202208

203209
return nil

0 commit comments

Comments
 (0)