move write lock to before verifyMsg

This commit is contained in:
Mike Seiler
2023-03-31 11:55:12 +02:00
committed by Maciej Witowski
parent e7033cf08c
commit 80c3b00da2
+3 -3
View File
@@ -878,9 +878,6 @@ func (mp *MessagePool) addTs(ctx context.Context, m *types.SignedMessage, curTs
return false, xerrors.Errorf("failed to get sender actor: %w", err)
}
mp.lk.Lock()
defer mp.lk.Unlock()
// This message can only be included in the _next_ epoch and beyond, hence the +1.
epoch := curTs.Height() + 1
nv := mp.api.StateNetworkVersion(ctx, epoch)
@@ -890,6 +887,9 @@ func (mp *MessagePool) addTs(ctx context.Context, m *types.SignedMessage, curTs
return false, xerrors.Errorf("sender actor %s is not a valid top-level sender", m.Message.From)
}
mp.lk.Lock()
defer mp.lk.Unlock()
publish, err := mp.verifyMsgBeforeAdd(ctx, m, curTs, local)
if err != nil {
return false, xerrors.Errorf("verify msg failed: %w", err)