forked from hailey.at/cocoon
An atproto PDS written in Go

support multiple cids in getblocks (#23)

authored by hailey.at and committed by GitHub 9fbd74c1 2face30c

Changed files
+7 -6
server
+7 -6
server/handle_sync_get_blocks.go
··· 2 2 3 3 import ( 4 4 "bytes" 5 - "context" 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 + ctx := e.Request().Context() 17 16 did := e.QueryParam("did") 18 - cidsstr := e.QueryParam("cids") 19 17 if did == "" { 20 18 return helpers.InputError(e, nil) 21 19 } 22 20 23 - cidstrs := strings.Split(cidsstr, ",") 24 - cids := []cid.Cid{} 21 + cidstrs, ok := e.QueryParams()["cids"] 22 + if !ok { 23 + return helpers.InputError(e, nil) 24 + } 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 - b, err := bs.Get(context.TODO(), c) 60 + b, err := bs.Get(ctx, c) 60 61 if err != nil { 61 62 return err 62 63 }