verifiedcar

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMalformedCar    = errors.New("malformed CAR")
	ErrBadVersion      = errors.New("bad CAR version")
	ErrBadRoots        = errors.New("CAR root CID mismatch")
	ErrUnexpectedBlock = errors.New("unexpected block in CAR")
	ErrExtraneousBlock = errors.New("extraneous block in CAR")
	ErrMissingBlock    = errors.New("missing block in CAR")
)

Functions

This section is empty.

Types

type BlockReader added in v0.11.0

type BlockReader interface {
	Next() (blocks.Block, error)
}

type Config

type Config struct {
	Root               cid.Cid        // The single root we expect to appear in the CAR and that we use to run our traversal against
	AllowCARv2         bool           // If true, allow CARv2 files to be received, otherwise strictly only allow CARv1
	Selector           datamodel.Node // The selector to execute, starting at the provided Root, to verify the contents of the CAR
	ExpectDuplicatesIn bool           // Handles whether the incoming stream has duplicates
	WriteDuplicatesOut bool           // Handles whether duplicates should be written a second time as blocks
	MaxBlocks          uint64         // set a budget for the traversal
}

func (Config) VerifyBlockStream added in v0.11.0

func (cfg Config) VerifyBlockStream(ctx context.Context, cbr BlockReader, lsys linking.LinkSystem) (uint64, uint64, error)

func (Config) VerifyCar added in v0.11.0

func (cfg Config) VerifyCar(ctx context.Context, rdr io.Reader, lsys linking.LinkSystem) (uint64, uint64, error)

Verify reads a CAR from the provided reader, verifies the contents are strictly what is specified by this Config and writes the blocks to the provided BlockWriteOpener. It returns the number of blocks and bytes written to the BlockWriteOpener.

Verification is performed according to the CAR construction rules contained within the Trustless, and Path Gateway specifications:

* https://specs.ipfs.tech/http-gateways/trustless-gateway/

* https://specs.ipfs.tech/http-gateways/path-gateway/

Jump to

Keyboard shortcuts

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