Skip to content

Commit 82ba0eb

Browse files
authored
[PSL-1232] prevent duplicate processing for base-file volumes (#910)
1 parent e9fb880 commit 82ba0eb

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

walletnode/api/services/cascade.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ func (service *CascadeAPIHandler) StartProcessing(ctx context.Context, p *cascad
127127
}
128128
log.WithContext(ctx).WithField("total_volumes", len(relatedFiles)).Info("Related volumes retrieved from the base file-id")
129129

130+
if isProcessingStarted(relatedFiles) {
131+
log.WithContext(ctx).Error("task registration is already in progress")
132+
return nil, cascade.MakeInternalServerError(errors.New("task registration is already in progress"))
133+
}
134+
130135
switch {
131136
case len(relatedFiles) == 1:
132137
baseFile := relatedFiles.GetBase()
@@ -238,6 +243,16 @@ func isDuplicateExists(burnTxIDs []string) bool {
238243
return false
239244
}
240245

246+
func isProcessingStarted(files types.Files) bool {
247+
for _, file := range files {
248+
if file.TaskID != "" {
249+
return true
250+
}
251+
}
252+
253+
return false
254+
}
255+
241256
func validateBurnTxID(burnTxID *string, burnTxIDs []string) (string, error) {
242257
if burnTxID != nil {
243258
return *burnTxID, nil

walletnode/services/cascaderegister/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ func (service *CascadeRegistrationService) RegisterVolumeTicket(ctx context.Cont
631631
return "", err
632632
}
633633

634-
if len(relatedFiles) <= 1 {
635-
return "", errors.New("related volumes must be greater than 1 for creating multi-volume ticket")
634+
if len(relatedFiles) == 1 {
635+
return "", nil
636636
}
637637

638638
concludedCount := 0

0 commit comments

Comments
 (0)