Skip to content

Commit

Permalink
fix: stop ec2 if no proof is generating
Browse files Browse the repository at this point in the history
  • Loading branch information
jyc228 committed Aug 28, 2023
1 parent 0da6feb commit cbef5d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/proof/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ func (s *Service) Prove(traceString string, proofType Type) (*ProveResponse, err
s.inProgressProof[id] = wg
go func(id, blockNumber string) {
defer wg.Done()
defer delete(s.inProgressProof, id)
defer func() {
s.mu.Lock()
delete(s.inProgressProof, id)
s.mu.Unlock()
if len(s.inProgressProof) == 0 {
s.ec2.StopIfRunning()
}
}()
log.Println("prove start.", "blockNumber:", blockNumber, "id:", id)
res, err := c.Prove(traceString, proofType)
log.Println("prove complete.", "blockNumber:", blockNumber, "id:", id, "err:", err)
Expand Down

0 comments on commit cbef5d0

Please sign in to comment.