Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

gx update and fix code to use new Cid type #5

Merged
merged 2 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.14: QmQLG22wSEStiociTSKQpZAuuaaWoF1B3iKyjPFvWiTQ77
1.1.0: QmYHXfGs5GVxXN233aFr5Jenvd7NG4qZ7pmjfyz7yvG93m
22 changes: 11 additions & 11 deletions blockservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -27,28 +27,28 @@
},
{
"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",
"language": "go",
"license": "",
"name": "go-blockservice",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "1.0.14"
"version": "1.1.0"
}

2 changes: 1 addition & 1 deletion test/blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down