Skip to content

Commit

Permalink
fix(manager): applylocalblock change mutex (#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
srene authored Aug 27, 2024
1 parent 9aff932 commit fe0f3cb
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 @@ -100,6 +100,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 @@ -112,12 +115,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 fe0f3cb

Please sign in to comment.