Skip to content

Commit

Permalink
chore: logs
Browse files Browse the repository at this point in the history
  • Loading branch information
anomit committed Nov 5, 2024
1 parent 58f06eb commit a4efba9
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkgs/dequeuer/submissionHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,25 @@ func (s *SubmissionHandler) verifyAndStoreSubmission(details SubmissionDetails)
}
}
}
// TODO: submission keys should be separated by data market address
key := redis.SubmissionKey(details.dataMarketAddress, details.submission.Request.EpochId, details.submission.Request.ProjectId, new(big.Int).SetUint64(details.submission.Request.SlotId).String())
key := redis.SubmissionKey(
details.dataMarketAddress,
details.submission.Request.EpochId,
details.submission.Request.ProjectId,
new(big.Int).SetUint64(details.submission.Request.SlotId).String(),
)
value := fmt.Sprintf("%s.%s", details.submissionId.String(), protojson.Format(details.submission))
set := redis.SubmissionSetByHeaderKey(details.dataMarketAddress, details.submission.Request.EpochId, details.submission.Header)
set := redis.SubmissionSetByHeaderKey(
details.dataMarketAddress,
details.submission.Request.EpochId,
details.submission.Header,
)

if val, _ := redis.Get(context.Background(), key); val != "" {
log.Debugln("Submission already exists: ", val)
return nil
}
if err := redis.SetSubmission(context.Background(), key, value, set, 20*time.Minute); err != nil {
log.Errorln("Error setting key-value pair: ", err.Error())
log.Errorf("Error setting submission in Redis (slot ID: %s, epoch ID: %d, project ID: %s): %s", strconv.FormatUint(details.submission.Request.SlotId, 10), details.submission.Request.EpochId, details.submission.Request.ProjectId, err.Error())
return err
}

Expand All @@ -279,7 +287,7 @@ func (s *SubmissionHandler) verifyAndStoreSubmission(details SubmissionDetails)
log.Errorf("Error serializing submission: %v", err)
return fmt.Errorf("json marshalling error: %s", err.Error())
}

// this htable is the raw dump of all submissions for a given epoch and data market, expires after 30 minutes
epochKey := redis.EpochSubmissionsKey(details.dataMarketAddress, details.submission.Request.EpochId)
if err := redis.RedisClient.HSet(context.Background(), epochKey, details.submissionId.String(), submissionJSON).Err(); err != nil {
log.Errorf("Failed to write submission details to Redis: %v", err)
Expand Down

0 comments on commit a4efba9

Please sign in to comment.