Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Aug 27, 2023
1 parent 1c1a2ca commit 00311aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 13 additions & 1 deletion code/go/0chain.net/blobbercore/challenge/challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
"github.com/0chain/gosdk/zboxcore/sdk"
"sort"
"strconv"
"time"
Expand Down Expand Up @@ -191,12 +192,23 @@ func (c *ChallengeEntity) getCommitTransaction() (*transaction.Transaction, erro
tx := datastore.GetStore().GetTransaction(ctx)

createdTime := common.ToTime(c.CreatedAt)

currentRound, err := sdk.GetRoundFromSharders()
if err != nil {
logging.Logger.Error("[challenge]verify: ",
zap.Any("challenge_id", c.ChallengeID),
zap.Time("created", createdTime),
zap.Error(err))
return nil, err
}

logging.Logger.Info("[challenge]commit",
zap.Any("current_round", currentRound),
zap.Any("challenge_id", c.ChallengeID),
zap.Time("created", createdTime),
zap.Any("openchallenge", c))

if c.RoundCreatedAt > config.StorageSCConfig.ChallengeCompletionTime {
if currentRound-c.RoundCreatedAt > config.StorageSCConfig.ChallengeCompletionTime {
c.CancelChallenge(ctx, ErrExpiredCCT)
if err := tx.Commit().Error; err != nil {
logging.Logger.Error("[challenge]verify(Commit): ",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.8.18-0.20230827173329-7676934170be
github.com/0chain/gosdk v1.8.18-0.20230827174144-b08022f0ee32
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/didip/tollbooth/v6 v6.1.2
github.com/go-openapi/runtime v0.26.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ github.com/0chain/gosdk v1.8.17-0.20230620144453-ce90e5c28d5c h1:uFZKXY+1BXrOz4O
github.com/0chain/gosdk v1.8.17-0.20230620144453-ce90e5c28d5c/go.mod h1:GgqNjoHBO0JN9TcpDAC28/VE2VsZi4MDr4qGdzfWV+I=
github.com/0chain/gosdk v1.8.18-0.20230827173329-7676934170be h1:hOb/jGAv3r7tHgfJjCb97yRrPHueB7HOiUjnXPBWQx8=
github.com/0chain/gosdk v1.8.18-0.20230827173329-7676934170be/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4=
github.com/0chain/gosdk v1.8.18-0.20230827174144-b08022f0ee32 h1:ia//80YWZAgi+8erUZUONshEV/zo8PRHVy32VNIuWwk=
github.com/0chain/gosdk v1.8.18-0.20230827174144-b08022f0ee32/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
Expand Down

0 comments on commit 00311aa

Please sign in to comment.