Skip to content

Commit 824e1a6

Browse files
authored
Merge pull request #22 from XWJACK/master
Adapt to the latest request method
2 parents 2143b8a + 3b7dab4 commit 824e1a6

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

api/service/api.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (a *API) blobSidecarHandler(w http.ResponseWriter, r *http.Request) {
179179

180180
blobSidecars := result.BlobSidecars
181181

182-
filteredBlobSidecars, err := filterBlobs(blobSidecars.Data, r.URL.Query().Get("indices"))
182+
filteredBlobSidecars, err := filterBlobs(blobSidecars.Data, r.URL.Query()["indices"])
183183
if err != nil {
184184
err.write(w)
185185
return
@@ -217,18 +217,18 @@ func (a *API) blobSidecarHandler(w http.ResponseWriter, r *http.Request) {
217217

218218
// filterBlobs filters the blobs based on the indices query provided.
219219
// If no indices are provided, all blobs are returned. If invalid indices are provided, an error is returned.
220-
func filterBlobs(blobs []*deneb.BlobSidecar, indices string) ([]*deneb.BlobSidecar, *httpError) {
221-
if indices == "" {
222-
return blobs, nil
223-
}
224-
225-
splits := strings.Split(indices, ",")
226-
if len(splits) == 0 {
220+
func filterBlobs(blobs []*deneb.BlobSidecar, _indices []string) ([]*deneb.BlobSidecar, *httpError) {
221+
var indices []string
222+
if len(_indices) == 0 {
227223
return blobs, nil
224+
} else if len(_indices) == 1 {
225+
indices = strings.Split(_indices[0], ",")
226+
} else {
227+
indices = _indices
228228
}
229229

230230
indicesMap := map[deneb.BlobIndex]struct{}{}
231-
for _, index := range splits {
231+
for _, index := range indices {
232232
parsedInt, err := strconv.ParseUint(index, 10, 64)
233233
if err != nil {
234234
return nil, newIndicesError(index)

api/service/api_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ func TestAPIService(t *testing.T) {
172172
},
173173
},
174174
},
175+
{
176+
name: "multi indices",
177+
path: "/eth/v1/beacon/blob_sidecars/1234?indices=0&indices=1",
178+
status: 200,
179+
expected: &storage.BlobSidecars{
180+
Data: blockTwo.BlobSidecars.Data,
181+
},
182+
},
175183
{
176184
name: "only index out of bounds returns empty array",
177185
path: "/eth/v1/beacon/blob_sidecars/1234?indices=3",

0 commit comments

Comments
 (0)