Skip to content

Commit

Permalink
applylocalblock fix
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Aug 22, 2024
1 parent 88ba1fe commit 963486f
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 @@ -95,6 +95,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 @@ -107,12 +110,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 963486f

Please sign in to comment.