Skip to content

Commit 0f8e872

Browse files
committed
gx update and fix code to use new Cid type
This commit was moved from ipfs/go-blockservice@4ba51bd
1 parent fe29b75 commit 0f8e872

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

blockservice/blockservice.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var ErrNotFound = errors.New("blockservice: key not found")
2525
// the blockservice.
2626
type BlockGetter interface {
2727
// GetBlock gets the requested block.
28-
GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error)
28+
GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error)
2929

3030
// GetBlocks does a batch request for the given cids, returning blocks as
3131
// they are found, in no particular order.
@@ -34,7 +34,7 @@ type BlockGetter interface {
3434
// be canceled). In that case, it will close the channel early. It is up
3535
// to the consumer to detect this situation and keep track which blocks
3636
// it has received and which it hasn't.
37-
GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block
37+
GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blocks.Block
3838
}
3939

4040
// BlockService is a hybrid block datastore. It stores data in a local
@@ -58,7 +58,7 @@ type BlockService interface {
5858
AddBlocks(bs []blocks.Block) error
5959

6060
// DeleteBlock deletes the given block from the blockservice.
61-
DeleteBlock(o *cid.Cid) error
61+
DeleteBlock(o cid.Cid) error
6262
}
6363

6464
type blockService struct {
@@ -196,7 +196,7 @@ func (s *blockService) AddBlocks(bs []blocks.Block) error {
196196

197197
// GetBlock retrieves a particular block from the service,
198198
// Getting it from the datastore using the key (hash).
199-
func (s *blockService) GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error) {
199+
func (s *blockService) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error) {
200200
log.Debugf("BlockService GetBlock: '%s'", c)
201201

202202
var f exchange.Fetcher
@@ -207,7 +207,7 @@ func (s *blockService) GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block,
207207
return getBlock(ctx, c, s.blockstore, f) // hash security
208208
}
209209

210-
func getBlock(ctx context.Context, c *cid.Cid, bs blockstore.Blockstore, f exchange.Fetcher) (blocks.Block, error) {
210+
func getBlock(ctx context.Context, c cid.Cid, bs blockstore.Blockstore, f exchange.Fetcher) (blocks.Block, error) {
211211
err := verifcid.ValidateCid(c) // hash security
212212
if err != nil {
213213
return nil, err
@@ -244,11 +244,11 @@ func getBlock(ctx context.Context, c *cid.Cid, bs blockstore.Blockstore, f excha
244244
// GetBlocks gets a list of blocks asynchronously and returns through
245245
// the returned channel.
246246
// NB: No guarantees are made about order.
247-
func (s *blockService) GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block {
247+
func (s *blockService) GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blocks.Block {
248248
return getBlocks(ctx, ks, s.blockstore, s.exchange) // hash security
249249
}
250250

251-
func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f exchange.Fetcher) <-chan blocks.Block {
251+
func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, f exchange.Fetcher) <-chan blocks.Block {
252252
out := make(chan blocks.Block)
253253

254254
go func() {
@@ -266,7 +266,7 @@ func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f e
266266
}
267267
ks = ks[:k]
268268

269-
var misses []*cid.Cid
269+
var misses []cid.Cid
270270
for _, c := range ks {
271271
hit, err := bs.Get(c)
272272
if err != nil {
@@ -303,7 +303,7 @@ func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f e
303303
}
304304

305305
// DeleteBlock deletes a block in the blockservice from the datastore
306-
func (s *blockService) DeleteBlock(c *cid.Cid) error {
306+
func (s *blockService) DeleteBlock(c cid.Cid) error {
307307
err := s.blockstore.DeleteBlock(c)
308308
if err == nil {
309309
log.Event(context.TODO(), "BlockService.BlockDeleted", c)
@@ -323,12 +323,12 @@ type Session struct {
323323
}
324324

325325
// GetBlock gets a block in the context of a request session
326-
func (s *Session) GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error) {
326+
func (s *Session) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error) {
327327
return getBlock(ctx, c, s.bs, s.ses) // hash security
328328
}
329329

330330
// GetBlocks gets blocks in the context of a request session
331-
func (s *Session) GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block {
331+
func (s *Session) GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blocks.Block {
332332
return getBlocks(ctx, ks, s.bs, s.ses) // hash security
333333
}
334334

blockservice/test/blocks_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestGetBlocksSequential(t *testing.T) {
7171
}
7272
objs := makeObjects(50)
7373

74-
var cids []*cid.Cid
74+
var cids []cid.Cid
7575
for _, o := range objs {
7676
cids = append(cids, o.Cid())
7777
servs[0].AddBlock(o)

0 commit comments

Comments
 (0)