Skip to content

Commit f204065

Browse files
committed
refactor(coordinator): refactor CollectProofs
1 parent eba7647 commit f204065

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

coordinator/manager.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (m *Manager) restorePrevSessions() {
196196
}
197197
m.sessions[sess.info.ID] = sess
198198
log.Info("Coordinator restart reload sessions", "ID", sess.info.ID, "sess", sess.info)
199-
go m.CollectProofs(sess.info.ID, sess)
199+
go m.CollectProofs(sess)
200200
}
201201
}
202202
}
@@ -308,7 +308,7 @@ func (m *Manager) handleZkProof(pk string, msg *message.ProofDetail) error {
308308
}
309309

310310
// CollectProofs collects proofs corresponding to a proof generation session.
311-
func (m *Manager) CollectProofs(id string, sess *session) {
311+
func (m *Manager) CollectProofs(sess *session) {
312312
timer := time.NewTimer(time.Duration(m.cfg.CollectionTime) * time.Minute)
313313

314314
for {
@@ -318,7 +318,7 @@ func (m *Manager) CollectProofs(id string, sess *session) {
318318

319319
// Ensure proper clean-up of resources.
320320
defer func() {
321-
delete(m.sessions, id)
321+
delete(m.sessions, sess.info.ID)
322322
m.mu.Unlock()
323323
}()
324324

@@ -335,13 +335,13 @@ func (m *Manager) CollectProofs(id string, sess *session) {
335335
// record failed session.
336336
errMsg := "proof generation session ended without receiving any valid proofs"
337337
m.addFailedSession(sess, errMsg)
338-
log.Warn(errMsg, "session id", id)
338+
log.Warn(errMsg, "session id", sess.info.ID)
339339
// Set status as skipped.
340340
// Note that this is only a workaround for testnet here.
341341
// TODO: In real cases we should reset to orm.ProvingTaskUnassigned
342342
// so as to re-distribute the task in the future
343-
if err := m.orm.UpdateProvingStatus(id, orm.ProvingTaskFailed); err != nil {
344-
log.Error("fail to reset task_status as Unassigned", "id", id, "err", err)
343+
if err := m.orm.UpdateProvingStatus(sess.info.ID, orm.ProvingTaskFailed); err != nil {
344+
log.Error("fail to reset task_status as Unassigned", "id", sess.info.I, "err", err)
345345
}
346346
return
347347
}
@@ -456,7 +456,7 @@ func (m *Manager) StartProofGenerationSession(task *orm.BlockBatch) (success boo
456456
m.mu.Lock()
457457
m.sessions[task.ID] = s
458458
m.mu.Unlock()
459-
go m.CollectProofs(task.ID, s)
459+
go m.CollectProofs(s)
460460

461461
return true
462462
}

0 commit comments

Comments
 (0)