Skip to content

Commit df7eb6f

Browse files
committed
Change statelocker mutex to RWMutex
1 parent a221792 commit df7eb6f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

rocketpool/node/collectors/state-locker.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ type StateLocker struct {
1010
state *state.NetworkState
1111

1212
// Internal fields
13-
lock *sync.Mutex
13+
lock *sync.RWMutex
1414
}
1515

1616
func NewStateLocker() *StateLocker {
1717
return &StateLocker{
18-
lock: &sync.Mutex{},
18+
lock: &sync.RWMutex{},
1919
}
2020
}
2121

@@ -26,7 +26,7 @@ func (l *StateLocker) UpdateState(state *state.NetworkState) {
2626
}
2727

2828
func (l *StateLocker) GetState() *state.NetworkState {
29-
l.lock.Lock()
30-
defer l.lock.Unlock()
29+
l.lock.RLock()
30+
defer l.lock.RUnlock()
3131
return l.state
3232
}

0 commit comments

Comments
 (0)