move write lock to before verifyMsg

This commit is contained in:
Mike Seiler 2023-03-28 12:35:09 -10:00
parent 2fa95a09be
commit 89b217ee21

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)