Skip to content

Commit efc3920

Browse files
authored
adaptation project name (#849)
1 parent f08d539 commit efc3920

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

service/apinode/api/http.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ func (s *httpServer) createTask(c *gin.Context) {
142142
return
143143
}
144144

145-
proj, err := s.projectManager.Project(req.ProjectID)
145+
projectID := req.ProjectID
146+
if strings.Contains(projectID, "delen-test") {
147+
projectID = "1009"
148+
}
149+
150+
proj, err := s.projectManager.Project(projectID)
146151
if err != nil {
147152
slog.Error("failed to get project", "error", err)
148153
c.JSON(http.StatusBadRequest, newErrResp(errors.Wrap(err, "failed to get project")))
@@ -211,7 +216,7 @@ func (s *httpServer) createTask(c *gin.Context) {
211216
DevicePubKey: hexutil.Encode(crypto.FromECDSAPub(matchedPubkey)),
212217
TaskID: taskID.Hex(),
213218
Nonce: req.Nonce,
214-
ProjectID: req.ProjectID,
219+
ProjectID: projectID,
215220
ProjectVersion: req.ProjectVersion,
216221
Payload: string(req.Payload),
217222
Signature: hexutil.Encode(sig),

vm/payload.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,16 @@ func encodeSumPayload(tasks []*task.Task, projectConfig *project.Config) ([]byte
199199
return nil, errors.New("sum project miss previous task")
200200
}
201201

202+
projectID := task.PrevTask.ProjectID.String()
203+
if projectID == "1009" {
204+
projectID = "delen-test"
205+
}
206+
202207
slog.Debug("--------------1")
203208
lastPayloadHash, _, _, lastData, err := api.HashTask(
204209
&api.CreateTaskReq{
205210
Nonce: task.PrevTask.Nonce,
206-
ProjectID: task.PrevTask.ProjectID.String(),
211+
ProjectID: projectID,
207212
ProjectVersion: task.PrevTask.ProjectVersion,
208213
Payload: task.PrevTask.Payload,
209214
}, projectConfig)
@@ -214,7 +219,7 @@ func encodeSumPayload(tasks []*task.Task, projectConfig *project.Config) ([]byte
214219
curPayloadHash, _, _, curData, err := api.HashTask(
215220
&api.CreateTaskReq{
216221
Nonce: task.Nonce,
217-
ProjectID: task.ProjectID.String(),
222+
ProjectID: projectID,
218223
ProjectVersion: task.ProjectVersion,
219224
Payload: task.Payload,
220225
}, projectConfig)

0 commit comments

Comments
 (0)