From 4ba51bde1832b5a073f32a3438b4fc26eedf229c Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Wed, 5 Sep 2018 03:12:54 -0400 Subject: [PATCH 1/2] gx update and fix code to use new Cid type --- blockservice.go | 22 +++++++++++----------- package.json | 20 ++++++++++---------- test/blocks_test.go | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/blockservice.go b/blockservice.go index d5c1882..a8d72e0 100644 --- a/blockservice.go +++ b/blockservice.go @@ -25,7 +25,7 @@ var ErrNotFound = errors.New("blockservice: key not found") // the blockservice. type BlockGetter interface { // GetBlock gets the requested block. - GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error) + GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error) // GetBlocks does a batch request for the given cids, returning blocks as // they are found, in no particular order. @@ -34,7 +34,7 @@ type BlockGetter interface { // be canceled). In that case, it will close the channel early. It is up // to the consumer to detect this situation and keep track which blocks // it has received and which it hasn't. - GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block + GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blocks.Block } // BlockService is a hybrid block datastore. It stores data in a local @@ -58,7 +58,7 @@ type BlockService interface { AddBlocks(bs []blocks.Block) error // DeleteBlock deletes the given block from the blockservice. - DeleteBlock(o *cid.Cid) error + DeleteBlock(o cid.Cid) error } type blockService struct { @@ -196,7 +196,7 @@ func (s *blockService) AddBlocks(bs []blocks.Block) error { // GetBlock retrieves a particular block from the service, // Getting it from the datastore using the key (hash). -func (s *blockService) GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error) { +func (s *blockService) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error) { log.Debugf("BlockService GetBlock: '%s'", c) var f exchange.Fetcher @@ -207,7 +207,7 @@ func (s *blockService) GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, return getBlock(ctx, c, s.blockstore, f) // hash security } -func getBlock(ctx context.Context, c *cid.Cid, bs blockstore.Blockstore, f exchange.Fetcher) (blocks.Block, error) { +func getBlock(ctx context.Context, c cid.Cid, bs blockstore.Blockstore, f exchange.Fetcher) (blocks.Block, error) { err := verifcid.ValidateCid(c) // hash security if err != nil { return nil, err @@ -244,11 +244,11 @@ func getBlock(ctx context.Context, c *cid.Cid, bs blockstore.Blockstore, f excha // GetBlocks gets a list of blocks asynchronously and returns through // the returned channel. // NB: No guarantees are made about order. -func (s *blockService) GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block { +func (s *blockService) GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blocks.Block { return getBlocks(ctx, ks, s.blockstore, s.exchange) // hash security } -func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f exchange.Fetcher) <-chan blocks.Block { +func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, f exchange.Fetcher) <-chan blocks.Block { out := make(chan blocks.Block) go func() { @@ -266,7 +266,7 @@ func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f e } ks = ks[:k] - var misses []*cid.Cid + var misses []cid.Cid for _, c := range ks { hit, err := bs.Get(c) if err != nil { @@ -303,7 +303,7 @@ func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f e } // DeleteBlock deletes a block in the blockservice from the datastore -func (s *blockService) DeleteBlock(c *cid.Cid) error { +func (s *blockService) DeleteBlock(c cid.Cid) error { err := s.blockstore.DeleteBlock(c) if err == nil { log.Event(context.TODO(), "BlockService.BlockDeleted", c) @@ -323,12 +323,12 @@ type Session struct { } // GetBlock gets a block in the context of a request session -func (s *Session) GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error) { +func (s *Session) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error) { return getBlock(ctx, c, s.bs, s.ses) // hash security } // GetBlocks gets blocks in the context of a request session -func (s *Session) GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block { +func (s *Session) GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blocks.Block { return getBlocks(ctx, ks, s.bs, s.ses) // hash security } diff --git a/package.json b/package.json index 8fb2092..bca5e67 100644 --- a/package.json +++ b/package.json @@ -9,15 +9,15 @@ "gxDependencies": [ { "author": "why", - "hash": "QmVDDgboX5nPUE4pBcK2xC1b9XbStA4t2KrUWBRMr9AiFd", + "hash": "QmQPWVDYeWvxN75cP4MGrbMVpADm2XqpM4KxgvbxkYk16u", "name": "go-bitswap", - "version": "1.0.15" + "version": "1.1.0" }, { "author": "hsanjuan", - "hash": "QmPuLWvxK1vg6ckKUpT53Dow9VLCcQGdL5Trwxa8PTLp7r", + "hash": "QmXHsHBveZF6ueKzDJbUg476gmrbzoR1yijiyH5SZAEuDT", "name": "go-ipfs-exchange-offline", - "version": "0.0.17" + "version": "0.1.0" }, { "author": "jbenet", @@ -27,21 +27,21 @@ }, { "author": "hsanjuan", - "hash": "Qmeg56ecxRnVv7VWViMrDeEMoBHaNFMs4vQnyQrJ79Zz7i", + "hash": "QmeMussyD8s3fQ3pM19ZsfbxvomEqPV9FvczLMWyBDYSnS", "name": "go-ipfs-blockstore", - "version": "0.0.20" + "version": "0.1.0" }, { "author": "stebalien", - "hash": "QmWAzSEoqZ6xU6pu8yL8e5WaMb7wtbfbhhN4p1DknUPtr3", + "hash": "QmRcHuYzAyswytBuMF78rj3LTChYszomRFXNg4685ZN1WM", "name": "go-block-format", - "version": "0.1.11" + "version": "0.2.0" }, { "author": "why", - "hash": "QmVUhfewLZpSaAiBYCpw2krYMaiVmFuhr2iurQLuRoU6sD", + "hash": "QmVkMRSkXrpjqrroEXWuYBvDBnXCdMMY6gsKicBGVGUqKT", "name": "go-verifcid", - "version": "0.0.4" + "version": "0.1.0" } ], "gxVersion": "0.12.1", diff --git a/test/blocks_test.go b/test/blocks_test.go index c3faa02..95f552d 100644 --- a/test/blocks_test.go +++ b/test/blocks_test.go @@ -71,7 +71,7 @@ func TestGetBlocksSequential(t *testing.T) { } objs := makeObjects(50) - var cids []*cid.Cid + var cids []cid.Cid for _, o := range objs { cids = append(cids, o.Cid()) servs[0].AddBlock(o) From b661dc371f9c7d20b53647ca9870ebe9e8f6fc6c Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Tue, 11 Sep 2018 22:13:01 -0400 Subject: [PATCH 2/2] gx publish 1.1.0 --- .gx/lastpubver | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gx/lastpubver b/.gx/lastpubver index 0786daf..7c04022 100644 --- a/.gx/lastpubver +++ b/.gx/lastpubver @@ -1 +1 @@ -1.0.14: QmQLG22wSEStiociTSKQpZAuuaaWoF1B3iKyjPFvWiTQ77 +1.1.0: QmYHXfGs5GVxXN233aFr5Jenvd7NG4qZ7pmjfyz7yvG93m diff --git a/package.json b/package.json index bca5e67..394c4b7 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,6 @@ "license": "", "name": "go-blockservice", "releaseCmd": "git commit -a -m \"gx publish $VERSION\"", - "version": "1.0.14" + "version": "1.1.0" }