Skip to content

Commit

Permalink
Add dispersing transistion check (Layr-Labs#741)
Browse files Browse the repository at this point in the history
Co-authored-by: Bowen Xue <[email protected]>
  • Loading branch information
bxue-l2 and Bowen Xue authored Sep 4, 2024
1 parent 57ef5f7 commit 9e4a8a1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions disperser/common/blobstore/shared_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const (
maxS3BlobFetchWorkers = 64
)

var errProcessingToDispersing = errors.New("blob transit to dispersing from non processing")

// The shared blob store that the disperser is operating on.
// The metadata store is backed by DynamoDB and the blob store is backed by S3.
//
Expand Down Expand Up @@ -158,6 +160,18 @@ func (s *SharedBlobStore) MarkBlobConfirmed(ctx context.Context, existingMetadat
}

func (s *SharedBlobStore) MarkBlobDispersing(ctx context.Context, metadataKey disperser.BlobKey) error {
refreshedMetadata, err := s.GetBlobMetadata(ctx, metadataKey)
if err != nil {
s.logger.Error("error getting blob metadata while marking blobDispersing", "err", err)
return err
}

status := refreshedMetadata.BlobStatus
if status != disperser.Processing {
s.logger.Error("error marking blob as dispersing from non processing state", "blobKey", metadataKey.String(), "status", status)
return errProcessingToDispersing
}

return s.blobMetadataStore.SetBlobStatus(ctx, metadataKey, disperser.Dispersing)
}

Expand Down

0 comments on commit 9e4a8a1

Please sign in to comment.