tangled
alpha
login
or
join now
willdot.net
/
cocoon
forked from
hailey.at/cocoon
0
fork
atom
An atproto PDS written in Go
0
fork
atom
overview
issues
pulls
pipelines
support multiple cids in getblocks
hailey.at
7 months ago
ae0f2342
2face30c
+7
-6
1 changed file
expand all
collapse all
unified
split
server
handle_sync_get_blocks.go
+7
-6
server/handle_sync_get_blocks.go
···
2
2
3
3
import (
4
4
"bytes"
5
5
-
"context"
6
6
-
"strings"
7
5
8
6
"github.com/bluesky-social/indigo/carstore"
9
7
"github.com/haileyok/cocoon/internal/helpers"
···
14
12
)
15
13
16
14
func (s *Server) handleGetBlocks(e echo.Context) error {
15
15
+
ctx := e.Request().Context()
17
16
did := e.QueryParam("did")
18
18
-
cidsstr := e.QueryParam("cids")
19
17
if did == "" {
20
18
return helpers.InputError(e, nil)
21
19
}
22
20
23
23
-
cidstrs := strings.Split(cidsstr, ",")
24
24
-
cids := []cid.Cid{}
21
21
+
cidstrs, ok := e.QueryParams()["cids"]
22
22
+
if !ok {
23
23
+
return helpers.InputError(e, nil)
24
24
+
}
25
25
+
var cids []cid.Cid
25
26
26
27
for _, cs := range cidstrs {
27
28
c, err := cid.Cast([]byte(cs))
···
56
57
bs := s.getBlockstore(urepo.Repo.Did)
57
58
58
59
for _, c := range cids {
59
59
-
b, err := bs.Get(context.TODO(), c)
60
60
+
b, err := bs.Get(ctx, c)
60
61
if err != nil {
61
62
return err
62
63
}