Skip to content

Commit

Permalink
Commit challenges in parallel (#698)
Browse files Browse the repository at this point in the history
* Commit challenges in parallel

* Fix lint issue

Co-authored-by: Lz <imlangzi@qq.com>
  • Loading branch information
avanaur and cnlangzi authored Jun 4, 2022
1 parent 3f45eca commit 7b9053d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions code/go/0chain.net/blobbercore/challenge/challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,18 @@ func commitProcessed(ctx context.Context) {
Order("sequence").
Find(&challenges)

for _, challenge := range challenges {
commitChallenge(challenge)
if len(challenges) > 0 {
swg := sizedwaitgroup.New(config.Configuration.ChallengeResolveNumWorkers)
for _, challenge := range challenges {
c := challenge
swg.Add()
go func() {
defer swg.Done()
commitChallenge(c)
}()
}
swg.Wait()
}

}

func commitChallenge(openchallenge *ChallengeEntity) {
Expand Down

0 comments on commit 7b9053d

Please sign in to comment.