Skip to content

Commit

Permalink
Made suggested changes.
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <[email protected]>
  • Loading branch information
cody-littley committed Nov 13, 2024
1 parent 5f60a52 commit 71ab20e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion disperser/apiserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
commonpb "github.com/Layr-Labs/eigenda/api/grpc/common"
pb "github.com/Layr-Labs/eigenda/api/grpc/disperser"
"github.com/Layr-Labs/eigenda/common"
healthcheck "github.com/Layr-Labs/eigenda/common/healthcheck"
"github.com/Layr-Labs/eigenda/common/healthcheck"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/auth"
"github.com/Layr-Labs/eigenda/core/meterer"
Expand Down
24 changes: 20 additions & 4 deletions relay/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ func (s *Server) GetBlob(ctx context.Context, request *pb.GetBlobRequest) (*pb.G
// - per-connection throttle
// - timeouts

keys := []v2.BlobKey{v2.BlobKey(request.BlobKey)}
key, err := v2.BytesToBlobKey(request.BlobKey)
if err != nil {
return nil, fmt.Errorf("invalid blob key: %w", err)
}

keys := []v2.BlobKey{key}
mMap, err := s.metadataServer.GetMetadataForBlobs(keys)
if err != nil {
return nil, fmt.Errorf(
Expand All @@ -94,7 +99,6 @@ func (s *Server) GetBlob(ctx context.Context, request *pb.GetBlobRequest) (*pb.G
return nil, fmt.Errorf("blob not found")
}

key := v2.BlobKey(request.BlobKey)
data, err := s.blobServer.GetBlob(key)
if err != nil {
return nil, fmt.Errorf("error fetching blob %s: %w", key.Hex(), err)
Expand All @@ -116,14 +120,26 @@ func (s *Server) GetChunks(ctx context.Context, request *pb.GetChunksRequest) (*
// - per-connection throttle
// - timeouts

if len(request.ChunkRequests) <= 0 {
return nil, fmt.Errorf("no chunk requests provided")
}

keys := make([]v2.BlobKey, 0, len(request.ChunkRequests))

for _, chunkRequest := range request.ChunkRequests {
var key v2.BlobKey
if chunkRequest.GetByIndex() != nil {
key = v2.BlobKey(chunkRequest.GetByIndex().GetBlobKey())
var err error
key, err = v2.BytesToBlobKey(chunkRequest.GetByIndex().GetBlobKey())
if err != nil {
return nil, fmt.Errorf("invalid blob key: %w", err)
}
} else {
key = v2.BlobKey(chunkRequest.GetByRange().GetBlobKey())
var err error
key, err = v2.BytesToBlobKey(chunkRequest.GetByRange().GetBlobKey())
if err != nil {
return nil, fmt.Errorf("invalid blob key: %w", err)
}
}
keys = append(keys, key)
}
Expand Down

0 comments on commit 71ab20e

Please sign in to comment.