Skip to content

Commit

Permalink
fix(manager): applylocalblock change mutex (#1036)
Browse files Browse the repository at this point in the history
(cherry picked from commit fe0f3cb)
  • Loading branch information
srene authored and omritoptix committed Aug 28, 2024
1 parent 515b847 commit f713b93
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions block/retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (m *Manager) syncFromDABatch() error {
}

func (m *Manager) applyLocalBlock(height uint64) error {
defer m.retrieverMu.Unlock()
m.retrieverMu.Lock()

block, err := m.Store.LoadBlock(height)
if err != nil {
return fmt.Errorf("load block: %w", gerrc.ErrNotFound)
Expand All @@ -96,12 +99,10 @@ func (m *Manager) applyLocalBlock(height uint64) error {
return fmt.Errorf("validate block from local store: height: %d: %w", height, err)
}

m.retrieverMu.Lock()
err = m.applyBlock(block, commit, types.BlockMetaData{Source: types.LocalDb})
if err != nil {
return fmt.Errorf("apply block from local store: height: %d: %w", height, err)
}
m.retrieverMu.Unlock()

return nil
}
Expand Down

0 comments on commit f713b93

Please sign in to comment.