From fe0f3cb63cd64cd8aa84d93e5d12cae681d1405e Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 27 Aug 2024 16:12:48 +0200 Subject: [PATCH] fix(manager): applylocalblock change mutex (#1036) --- block/retriever.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/retriever.go b/block/retriever.go index 75f12f01d..1987012b0 100644 --- a/block/retriever.go +++ b/block/retriever.go @@ -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) @@ -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 }