Skip to content

Commit

Permalink
coreapi: update block after update
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <[email protected]>
  • Loading branch information
magik6k committed Jan 30, 2018
1 parent bb6bf4c commit 708492c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions core/coreapi/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options"

mh "gx/ipfs/QmYeKnKpubCMRiq3PGZcTREErthbb5Q9cXsCoSkD9bjEBd/go-multihash"
blocks "gx/ipfs/QmYsEQydGrsxNZfAiskvQ76N2xE9hDQtSAkRSynwMiUK3c/go-block-format"
cid "gx/ipfs/QmeSrf6pzut73u6zLQkRFQ3ygt3k6XFT2kjdYP8Tnkwwyg/go-cid"
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
)

type BlockAPI struct {
Expand Down Expand Up @@ -63,12 +63,12 @@ func (api *BlockAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Bloc
return nil, err
}

k, err := api.node.Blocks.AddBlock(b)
err = api.node.Blocks.AddBlock(b)
if err != nil {
return nil, err
}

return ParseCid(k), nil
return ParseCid(b.Cid()), nil
}

func (api *BlockAPI) Get(ctx context.Context, p coreiface.Path) (io.Reader, error) {
Expand Down
2 changes: 1 addition & 1 deletion core/coreapi/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

mh "gx/ipfs/QmYeKnKpubCMRiq3PGZcTREErthbb5Q9cXsCoSkD9bjEBd/go-multihash"
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
)

func TestBlockPut(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions core/coreapi/interface/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ type BlockStat interface {
type CoreAPI interface {
// Unixfs returns an implementation of Unixfs API.
Unixfs() UnixfsAPI

// Block returns an implementation of Block API.
Block() BlockAPI

// Dag returns an implementation of Dag API.
Dag() DagAPI

// Name returns an implementation of Name API.
Name() NameAPI

// Key returns an implementation of Key API.
Key() KeyAPI

Expand Down

0 comments on commit 708492c

Please sign in to comment.