Skip to content

Commit

Permalink
[PSL-1187] updated payload to handle empty burn txid/txids
Browse files Browse the repository at this point in the history
  • Loading branch information
j-rafique committed Jun 27, 2024
1 parent 3b365ae commit ee4b249
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 64 deletions.
6 changes: 1 addition & 5 deletions walletnode/api/design/cascade.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,10 @@ var StartCascadeProcessingPayload = Type("StartCascadeProcessingPayload", func()
})
Attribute("burn_txid", String, func() {
Description("Burn transaction ID")
MinLength(64)
MaxLength(64)
Example("576e7b824634a488a2f0baacf5a53b237d883029f205df25b300b87c8877ab58")
})
Attribute("burn_txids", ArrayOf(String), func() {
Description("List of Burn transaction IDs for multi-volume registration")
MinLength(64)
MaxLength(64)
Example([]string{
"576e7b824634a488a2f0baacf5a53b237d883029f205df25b300b87c8877ab58",
})
Expand Down Expand Up @@ -328,7 +324,7 @@ var StartCascadeProcessingPayload = Type("StartCascadeProcessingPayload", func()
Example("Basic abcdef12345")
})

Required("file_id", "burn_txid", "app_pastelid", "key")
Required("file_id", "app_pastelid", "key")
})

// FileRegistrationDetailPayload - Payload for registration detail
Expand Down
2 changes: 1 addition & 1 deletion walletnode/api/gen/cascade/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions walletnode/api/gen/http/cascade/client/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion walletnode/api/gen/http/cascade/client/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 1 addition & 20 deletions walletnode/api/gen/http/cascade/server/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion walletnode/api/gen/http/openapi.json

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions walletnode/api/gen/http/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,6 @@ paths:
schema:
$ref: '#/definitions/CascadeStartProcessingRequestBody'
required:
- burn_txid
- app_pastelid
responses:
"201":
Expand Down Expand Up @@ -2637,8 +2636,6 @@ definitions:
type: string
description: Burn transaction ID
example: 576e7b824634a488a2f0baacf5a53b237d883029f205df25b300b87c8877ab58
minLength: 64
maxLength: 64
burn_txids:
type: array
items:
Expand All @@ -2647,8 +2644,6 @@ definitions:
description: List of Burn transaction IDs for multi-volume registration
example:
- 576e7b824634a488a2f0baacf5a53b237d883029f205df25b300b87c8877ab58
minItems: 64
maxItems: 64
make_publicly_accessible:
type: boolean
description: To make it publicly accessible
Expand All @@ -2669,7 +2664,6 @@ definitions:
make_publicly_accessible: false
spendable_address: PtiqRXn2VQwBjp1K8QXR2uW2w2oZ3Ns7N6j
required:
- burn_txid
- app_pastelid
CascadeStartProcessingResponseBody:
title: 'Mediatype identifier: application/sense.start-processing; view=default'
Expand Down
2 changes: 1 addition & 1 deletion walletnode/api/gen/http/openapi3.json

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions walletnode/api/gen/http/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40813,8 +40813,6 @@ components:
type: string
description: Burn transaction ID
example: 576e7b824634a488a2f0baacf5a53b237d883029f205df25b300b87c8877ab58
minLength: 64
maxLength: 64
burn_txids:
type: array
items:
Expand All @@ -40823,8 +40821,6 @@ components:
description: List of Burn transaction IDs for multi-volume registration
example:
- 576e7b824634a488a2f0baacf5a53b237d883029f205df25b300b87c8877ab58
minItems: 64
maxItems: 64
make_publicly_accessible:
type: boolean
description: To make it publicly accessible
Expand All @@ -40845,7 +40841,6 @@ components:
make_publicly_accessible: false
spendable_address: PtiqRXn2VQwBjp1K8QXR2uW2w2oZ3Ns7N6j
required:
- burn_txid
- app_pastelid
StartProcessingRequestBody2:
type: object
Expand Down
15 changes: 10 additions & 5 deletions walletnode/api/services/cascade.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,20 @@ func (service *CascadeAPIHandler) StartProcessing(ctx context.Context, p *cascad
}

sortedBurnTxids, err := service.register.SortBurnTxIDs(ctx, p.BurnTxids)
if err == nil {
if err != nil {
return nil, cascade.MakeInternalServerError(err)
}

sortedRelatedFiles := service.register.SortFilesWithHigherAmounts(relatedFiles)
if err == nil {
return nil, cascade.MakeInternalServerError(err)
if len(sortedRelatedFiles) < 1 {
log.WithContext(ctx).WithField("sorted_related_files", sortedRelatedFiles).Info("Sorted related files")
return nil, cascade.MakeInternalServerError(errors.New("Sorted related files"))
}
log.WithContext(ctx).WithField("sorted_related_files", sortedRelatedFiles).Info("Sorted related files")

var taskIDs string
for index, file := range relatedFiles {
p.BurnTxid = sortedBurnTxids[index]
txid := sortedBurnTxids[index]
p.BurnTxid = &txid
taskID, err := service.register.ProcessFile(ctx, *file, p)
if err != nil {
log.WithContext(ctx).WithField("file_id", file.FileID).WithError(err).Error("error processing volume")
Expand All @@ -167,6 +168,10 @@ func (service *CascadeAPIHandler) StartProcessing(ctx context.Context, p *cascad
taskIDs = taskIDs[:len(taskIDs)-1]
}
}

return &cascade.StartProcessingResult{
TaskID: taskIDs,
}, nil
}

return res, nil
Expand Down
7 changes: 1 addition & 6 deletions walletnode/services/cascaderegister/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ func (service *CascadeRegistrationService) AddTask(p *cascade.StartProcessingPay
return "", errors.Errorf("write image data to file: %v", err)
}

// Set the file format based on the filename extension
if err := file.SetFormatFromExtension(filepath.Ext(filename)); err != nil {
return "", errors.Errorf("set file format: %v", err)
}

// Assign the newly created File instance to the request
request.Image = file

Expand Down Expand Up @@ -495,7 +490,7 @@ func (service *CascadeRegistrationService) ProcessFile(ctx context.Context, file
}

file.TaskID = taskID
file.BurnTxnID = p.BurnTxid
file.BurnTxnID = *p.BurnTxid
err = service.UpsertFile(file)
if err != nil {
log.WithField("task_id", taskID).WithField("file_id", p.FileID).
Expand Down
2 changes: 1 addition & 1 deletion walletnode/services/cascaderegister/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// FromStartProcessingPayload convert StartProcessingPayload to ActionRegistrationRequest
func FromStartProcessingPayload(payload *cascade.StartProcessingPayload) *common.ActionRegistrationRequest {
req := &common.ActionRegistrationRequest{
BurnTxID: payload.BurnTxid,
BurnTxID: *payload.BurnTxid,
AppPastelID: payload.AppPastelID,
AppPastelIDPassphrase: payload.Key,
MakePubliclyAccessible: payload.MakePubliclyAccessible,
Expand Down

0 comments on commit ee4b249

Please sign in to comment.