pieceio

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2020 License: Apache-2.0, MIT Imports: 15 Imported by: 0

README

pieceio

The pieceio module is a collection of structs for generating piece commitments (a.k.a. CommP) and storing pieces for storage market deals. It is used by the storagemarket module.

Installation

go get github.com/filecoin-project/go-fil-markets/pieceio

PieceIO

PieceIO is used by storagemarket client for proposing deals.

To initialize a PieceIO:

package pieceio

func NewPieceIO(carIO CarIO, bs blockstore.Blockstore) PieceIO

Parameters

PieceIOWithStore

PieceIOWithStore is PieceIO with a filestore. It is used by storagemarket provider to store pieces, and to generate and store piece commitments and piece metadata for deals.

To initialize a PieceIOWithStore:

package pieceio

func NewPieceIOWithStore(carIO CarIO, store filestore.FileStore, bs blockstore.Blockstore) PieceIOWithStore

Parameters

CarIO

CarIO is a utility module that wraps github.com/ipld/go-car for use by storagemarket.

To initialize a CarIO:

package cario

func NewCarIO() pieceio.CarIO

Please the tests for more information about expected behavior.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePieceCIDFromFile added in v0.6.0

func GeneratePieceCIDFromFile(proofType abi.RegisteredSealProof, piece io.Reader, pieceSize abi.UnpaddedPieceSize) (cid.Cid, error)

func GeneratePieceCommitment

func GeneratePieceCommitment(rt abi.RegisteredSealProof, rd io.Reader, pieceSize uint64) (cid.Cid, abi.UnpaddedPieceSize, error)

func ToReadableFile added in v0.6.0

func ToReadableFile(r io.Reader, n int64) (*os.File, func() error, error)

Types

type CarIO

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, userOnNewCarBlocks ...car.OnNewCarBlockFunc) error

	// PrepareCar prepares a car so that its total size can be calculated without writing it to a file.
	// It can then be written with PreparedCar.Dump
	PrepareCar(ctx context.Context, bs ReadStore, payloadCid cid.Cid, node ipld.Node, userOnNewCarBlocks ...car.OnNewCarBlockFunc) (PreparedCar, error)

	// LoadCar loads blocks into the a store from a given CAR file
	LoadCar(bs WriteStore, r io.Reader) (cid.Cid, error)
}

type MultiStore added in v0.5.2

type MultiStore interface {
	Get(i multistore.StoreID) (*multistore.Store, error)
}

type PieceIO

type PieceIO interface {
	GeneratePieceReader(payloadCid cid.Cid, selector ipld.Node, storeID *multistore.StoreID, userOnNewCarBlocks ...car.OnNewCarBlockFunc) (io.ReadCloser, uint64, error, <-chan error)
	GeneratePieceCommitment(rt abi.RegisteredSealProof, payloadCid cid.Cid, selector ipld.Node, storeID *multistore.StoreID, userOnNewCarBlocks ...car.OnNewCarBlockFunc) (cid.Cid, abi.UnpaddedPieceSize, error)
	ReadPiece(storeID *multistore.StoreID, r io.Reader) (cid.Cid, error)
}

PieceIO converts between payloads and pieces

func NewPieceIO

func NewPieceIO(carIO CarIO, bs blockstore.Blockstore, multiStore MultiStore) PieceIO

type PreparedCar

type PreparedCar interface {
	Size() uint64
	Dump(w io.Writer) error
}

type ReadStore

type ReadStore interface {
	Get(cid.Cid) (blocks.Block, error)
}

type WriteStore

type WriteStore interface {
	Put(blocks.Block) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL