Skip to content

Commit

Permalink
feat(pieceio): remove onnewcarblock params
Browse files Browse the repository at this point in the history
defer solving writing all cid locations to a seperate ticket
  • Loading branch information
hannahhoward committed Feb 4, 2020
1 parent 962f8ad commit 2d5ae07
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
4 changes: 2 additions & 2 deletions pieceio/cario/cario.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func NewCarIO() pieceio.CarIO {
return &carIO{}
}

func (c carIO) WriteCar(ctx context.Context, bs pieceio.ReadStore, payloadCid cid.Cid, selector ipld.Node, w io.Writer, onNewCarBlockFuncs ...car.OnNewCarBlockFunc) error {
func (c carIO) WriteCar(ctx context.Context, bs pieceio.ReadStore, payloadCid cid.Cid, selector ipld.Node, w io.Writer) error {
sc := car.NewSelectiveCar(ctx, bs, []car.Dag{{Root: payloadCid, Selector: selector}})
return sc.Write(w, onNewCarBlockFuncs...)
return sc.Write(w)
}

func (c carIO) PrepareCar(ctx context.Context, bs pieceio.ReadStore, payloadCid cid.Cid, selector ipld.Node) (pieceio.PreparedCar, error) {
Expand Down
18 changes: 5 additions & 13 deletions pieceio/mocks/CarIO.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions pieceio/pieceio.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/filecoin-project/go-padreader"
"github.com/filecoin-project/go-sectorbuilder"
"github.com/ipfs/go-car"
"github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"
"github.com/ipld/go-ipld-prime"
Expand All @@ -23,7 +22,7 @@ type PreparedCar interface {

type CarIO interface {
// WriteCar writes a given payload to a CAR file and into the passed IO stream
WriteCar(ctx context.Context, bs ReadStore, payloadCid cid.Cid, node ipld.Node, w io.Writer, onNewCarBlockFuncs ...car.OnNewCarBlockFunc) error
WriteCar(ctx context.Context, bs ReadStore, payloadCid cid.Cid, node ipld.Node, w io.Writer) error

// PrepareCar prepares a car so that it's total size can be calculated without writing it to a file.
// It can then be written with PreparedCar.Dump
Expand Down Expand Up @@ -87,7 +86,7 @@ func (pio *pieceIO) GeneratePieceCommitment(payloadCid cid.Cid, selector ipld.No
return commitment, paddedSize, nil
}

func (pio *pieceIOWithStore) GeneratePieceCommitmentToFile(payloadCid cid.Cid, selector ipld.Node, onNewCarBlockFuncs ...car.OnNewCarBlockFunc) ([]byte, filestore.Path, uint64, error) {
func (pio *pieceIOWithStore) GeneratePieceCommitmentToFile(payloadCid cid.Cid, selector ipld.Node) ([]byte, filestore.Path, uint64, error) {
f, err := pio.store.CreateTemp()
if err != nil {
return nil, "", 0, err
Expand Down
3 changes: 1 addition & 2 deletions pieceio/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/filecoin-project/go-fil-markets/filestore"

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-car"
"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime"
)
Expand All @@ -27,5 +26,5 @@ type PieceIO interface {

type PieceIOWithStore interface {
PieceIO
GeneratePieceCommitmentToFile(payloadCid cid.Cid, selector ipld.Node, onNewCarBlockFuncs ...car.OnNewCarBlockFunc) ([]byte, filestore.Path, uint64, error)
GeneratePieceCommitmentToFile(payloadCid cid.Cid, selector ipld.Node) ([]byte, filestore.Path, uint64, error)
}

0 comments on commit 2d5ae07

Please sign in to comment.