Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get blob metadata by account id #622

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions disperser/common/blobstore/blob_metadata_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
)

const (
statusIndexName = "StatusIndex"
batchIndexName = "BatchIndex"
statusIndexName = "StatusIndex"
batchIndexName = "BatchIndex"
accountIDRequestedAtIndexName = "AccountID-RequestedAt-Index"
)

// BlobMetadataStore is a blob metadata storage backed by DynamoDB
Expand Down Expand Up @@ -166,6 +167,30 @@ func (s *BlobMetadataStore) GetBlobMetadataByStatusWithPagination(ctx context.Co
return metadata, exclusiveStartKey, nil
}

// GetBlobMetadataByAccountIdRequestedAt returns all the metadata with the given accountID after the given requestedAt timestamp
func (s *BlobMetadataStore) GetBlobMetadataByAccountIdRequestedAt(ctx context.Context, accountID string, requestedAt uint64) ([]*disperser.BlobMetadata, error) {
items, err := s.dynamoDBClient.QueryIndex(ctx, s.tableName, accountIDRequestedAtIndexName, "AccountID = :account_id AND RequestedAt > :requested_at", commondynamodb.ExpresseionValues{
":account_id": &types.AttributeValueMemberS{
Value: accountID,
},
":requested_at": &types.AttributeValueMemberN{
Value: strconv.Itoa(int(requestedAt)),
}})
if err != nil {
return nil, err
}

metadata := make([]*disperser.BlobMetadata, len(items))
for i, item := range items {
metadata[i], err = UnmarshalBlobMetadata(item)
if err != nil {
return nil, err
}
}

return metadata, nil
}

func (s *BlobMetadataStore) GetAllBlobMetadataByBatch(ctx context.Context, batchHeaderHash [32]byte) ([]*disperser.BlobMetadata, error) {
items, err := s.dynamoDBClient.QueryIndex(ctx, s.tableName, batchIndexName, "BatchHeaderHash = :batch_header_hash", commondynamodb.ExpresseionValues{
":batch_header_hash": &types.AttributeValueMemberB{
Expand Down
Loading