+6
-7
server/handle_sync_get_blocks.go
+6
-7
server/handle_sync_get_blocks.go
···
2
3
import (
4
"bytes"
5
6
"github.com/bluesky-social/indigo/carstore"
7
"github.com/haileyok/cocoon/internal/helpers"
···
12
)
13
14
func (s *Server) handleGetBlocks(e echo.Context) error {
15
-
ctx := e.Request().Context()
16
did := e.QueryParam("did")
17
if did == "" {
18
return helpers.InputError(e, nil)
19
}
20
21
-
cidstrs, ok := e.QueryParams()["cids"]
22
-
if !ok {
23
-
return helpers.InputError(e, nil)
24
-
}
25
-
var cids []cid.Cid
26
27
for _, cs := range cidstrs {
28
c, err := cid.Cast([]byte(cs))
···
57
bs := s.getBlockstore(urepo.Repo.Did)
58
59
for _, c := range cids {
60
-
b, err := bs.Get(ctx, c)
61
if err != nil {
62
return err
63
}
···
2
3
import (
4
"bytes"
5
+
"context"
6
+
"strings"
7
8
"github.com/bluesky-social/indigo/carstore"
9
"github.com/haileyok/cocoon/internal/helpers"
···
14
)
15
16
func (s *Server) handleGetBlocks(e echo.Context) error {
17
did := e.QueryParam("did")
18
+
cidsstr := e.QueryParam("cids")
19
if did == "" {
20
return helpers.InputError(e, nil)
21
}
22
23
+
cidstrs := strings.Split(cidsstr, ",")
24
+
cids := []cid.Cid{}
25
26
for _, cs := range cidstrs {
27
c, err := cid.Cast([]byte(cs))
···
56
bs := s.getBlockstore(urepo.Repo.Did)
57
58
for _, c := range cids {
59
+
b, err := bs.Get(context.TODO(), c)
60
if err != nil {
61
return err
62
}