fix(coordinator): concurrent map write (#360)

Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
This commit is contained in:
colin
2023-03-14 06:04:47 +08:00
committed by GitHub
parent 31c6d965a7
commit da0ee76991

View File

@@ -368,7 +368,7 @@ func (m *Manager) CollectProofs(sess *session) {
finished, validRollers := sess.isRollersFinished()
//When all rollers have finished submitting their tasks, select a winner within rollers with valid proof, and return, terminate the for loop.
if finished {
if finished && len(validRollers) > 0 {
//Select a random index for this slice.
randIndex := mathrand.Intn(len(validRollers))
_ = validRollers[randIndex]
@@ -543,6 +543,8 @@ func (m *Manager) IsRollerIdle(hexPk string) bool {
}
func (m *Manager) addFailedSession(sess *session, errMsg string) {
m.mu.Lock()
defer m.mu.Unlock()
m.failedSessionInfos[sess.info.ID] = newSessionInfo(sess, types.ProvingTaskFailed, errMsg, true)
}