Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultWalkFunc(nd format.Node) ([]*format.Link, error)
- func HeaderSize(h *CarHeader) (uint64, error)
- func LdRead(r *bufio.Reader) ([]byte, error)
- func LdSize(d ...[]byte) uint64
- func LdWrite(w io.Writer, d ...[]byte) error
- func ReadCid(buf []byte) (cid.Cid, int, error)deprecated
- func ReadNode(br *bufio.Reader) (cid.Cid, []byte, error)
- func Walk(ctx context.Context, getLinks GetLinks, c cid.Cid, visit func(cid.Cid) bool, ...) error
- func WalkDepth(ctx context.Context, getLinks GetLinks, c cid.Cid, ...) error
- func WriteCar(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.Writer, ...) error
- func WriteCarWithWalker(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.Writer, ...) error
- func WriteHeader(h *CarHeader, w io.Writer) error
- type BytesReader
- type CarHeader
- type CarReader
- type Client
- type Deal
- type DealStatus
- type GetLinks
- type ListOption
- type Option
- type Pin
- type PinOption
- type PinResponse
- type PinResponseDetail
- type PinStatus
- type PutOption
- type ReadStore
- type Status
- type Store
- type TrackerStatus
- type WalkFunc
- type WalkOption
- type Web3Response
Constants ¶
const ( PinStatusPinned = PinStatus(TrackerStatusPinned) PinStatusPinning = PinStatus(TrackerStatusPinning) PinStatusPinQueued = PinStatus(TrackerStatusPinQueued) PinStatusRemote = PinStatus(TrackerStatusRemote) PinStatusUnpinned = PinStatus(TrackerStatusUnpinned) PinStatusUnknown = PinStatus(-1) )
Variables ¶
var MaxAllowedSectionSize uint = 32 << 20 // 32MiB
MaxAllowedSectionSize dictates the maximum number of bytes that a CARv1 header or section is allowed to occupy without causing a decode to error. This cannot be supplied as an option, only adjusted as a global. You should use v2#NewReader instead since it allows for options to be passed in.
Functions ¶
func HeaderSize ¶
func Walk ¶
func Walk(ctx context.Context, getLinks GetLinks, c cid.Cid, visit func(cid.Cid) bool, options ...WalkOption) error
WalkGraph will walk the dag in order (depth first) starting at the given root.
func WalkDepth ¶
func WalkDepth(ctx context.Context, getLinks GetLinks, c cid.Cid, visit func(cid.Cid, int) bool, options ...WalkOption) error
WalkDepth walks the dag starting at the given root and passes the current depth to a given visit function. The visit function can be used to limit DAG exploration.
func WriteCar ¶
func WriteCar(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.Writer, options ...WalkOption) error
func WriteCarWithWalker ¶
func WriteCarWithWalker(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.Writer, walk WalkFunc, options ...WalkOption) error
Types ¶
type BytesReader ¶
type BytesReader interface { io.Reader io.ByteReader }
type CarReader ¶
type CarReader struct { Header *CarHeader // contains filtered or unexported fields }
type Client ¶
type Client interface { Get(context.Context, cid.Cid) (*Web3Response, error) //Put(context.Context, fs.File, ...PutOption) (cid.Cid, error) PutCar(context.Context, io.Reader) (cid.Cid, error) Status(context.Context, cid.Cid) (*Status, error) //List(context.Context, ...ListOption) (*UploadIterator, error) Pin(context.Context, cid.Cid, ...PinOption) (*PinResponse, error) GetName(context.Context, string) (*ipns_pb.IpnsEntry, error) PutName(context.Context, *ipns_pb.IpnsEntry, string) error GetAuthToken() string SetAuthToken(string) }
Client is a HTTP API client to the web3.storage service.
type Deal ¶
type Deal struct { DealID uint64 //StorageProvider address.Address Status DealStatus PieceCid cid.Cid DataCid cid.Cid DataModelSelector string Activation time.Time Created time.Time Updated time.Time }
func (*Deal) UnmarshalJSON ¶
type DealStatus ¶
type DealStatus int
const ( DealStatusQueued DealStatus = iota DealStatusPublished DealStatusActive )
func (DealStatus) String ¶
func (s DealStatus) String() string
type GetLinks ¶
func GetLinksWithDAG ¶
func GetLinksWithDAG(ng format.NodeGetter) GetLinks
type ListOption ¶
type ListOption func(cfg *listConfig) error
ListOption is an option configuring a call to List.
func WithBefore ¶
func WithBefore(before time.Time) ListOption
WithBefore sets the time that items in the list were uploaded before.
func WithMaxResults ¶
func WithMaxResults(maxResults int) ListOption
WithMaxResults sets the maximum number of results that will be available from the iterator.
type Option ¶
type Option func(cfg *clientConfig) error
Option is an option configuring a web3.storage client.
func WithEndpoint ¶
WithEndpoint sets the URL of the root API when making requests (default https://api.web3.storage).
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client to use when making requests which allows timeouts and redirect behaviour to be configured. The default is to use the DefaultClient from the Go standard library.
type Pin ¶
func (*Pin) UnmarshalJSON ¶
type PinOption ¶
type PinOption func(cfg *pinConfig) error
PinOption is an option configuring a call to Pin.
func WithPinMeta ¶
WithPinMeta adds metadata about pinned data.
func WithPinName ¶
WithPinName sets the name to use for the pinned data.
func WithPinOrigin ¶
WithPinOrigin adds a multiaddr known to provide the data.
type PinResponse ¶
type PinResponse struct { RequestID string Status string Created time.Time Pin PinResponseDetail Delegates []string }
func (*PinResponse) UnmarshalJSON ¶
func (p *PinResponse) UnmarshalJSON(b []byte) error
type PinResponseDetail ¶
type PinResponseDetail struct { Cid cid.Cid SourceCid cid.Cid ContentCid cid.Cid Name string Origins []string Meta map[string]string Deleted time.Time Created time.Time Updated time.Time Pins []Pin }
func (*PinResponseDetail) UnmarshalJSON ¶
func (p *PinResponseDetail) UnmarshalJSON(b []byte) error
type PutOption ¶
type PutOption func(cfg *putConfig) error
PutOption is an option configuring a call to Put.
func WithDirname ¶
WithDirname sets the root directory path, for use when the provided file is a directory and does NOT implement fs.ReadDirFile. The default is "", which will resolve to the current working directory if the file system interface is the default (the OS).
type Status ¶
Status is IPFS pin and Filecoin deal status for a given CID.
func (*Status) UnmarshalJSON ¶
type TrackerStatus ¶
type TrackerStatus int
const ( // IPFSStatus should never take this value. // When used as a filter. It means "all". TrackerStatusUndefined TrackerStatus = 0 // The cluster node is offline or not responding TrackerStatusClusterError TrackerStatus = 1 << iota // An error occurred pinning TrackerStatusPinError // An error occurred unpinning TrackerStatusUnpinError // The IPFS daemon has pinned the item TrackerStatusPinned // The IPFS daemon is currently pinning the item TrackerStatusPinning // The IPFS daemon is currently unpinning the item TrackerStatusUnpinning // The IPFS daemon is not pinning the item TrackerStatusUnpinned // The IPFS daemon is not pinning the item but it is being tracked TrackerStatusRemote // The item has been queued for pinning on the IPFS daemon TrackerStatusPinQueued // The item has been queued for unpinning on the IPFS daemon TrackerStatusUnpinQueued // The IPFS daemon is not pinning the item through this cid but it is // tracked in a cluster dag TrackerStatusSharded // The item is in the state and should be pinned, but // it is however not pinned and not queued/pinning. TrackerStatusUnexpectedlyUnpinned )
type WalkOption ¶
type WalkOption func(*walkOptions)
WalkOption is a setter for walkOptions
func Concurrency ¶
func Concurrency(worker int) WalkOption
Concurrency is a WalkOption indicating that node fetching should be done in parallel, with a specific concurrency factor. NOTE: When using that option, the walk order is *not* guarantee. NOTE: It *does not* make multiple concurrent calls to the passed `visit` function.
func Concurrent ¶
func Concurrent() WalkOption
Concurrent is a WalkOption indicating that node fetching should be done in parallel, with the default concurrency factor. NOTE: When using that option, the walk order is *not* guarantee. NOTE: It *does not* make multiple concurrent calls to the passed `visit` function.
func IgnoreErrors ¶
func IgnoreErrors() WalkOption
IgnoreErrors is a WalkOption indicating that the walk should attempt to continue even when an error occur.
func IgnoreMissing ¶
func IgnoreMissing() WalkOption
IgnoreMissing is a WalkOption indicating that the walk should continue when a node is missing.
func OnError ¶
func OnError(handler func(c cid.Cid, err error) error) WalkOption
OnError is a WalkOption adding a custom error handler. If this handler return a nil error, the walk will continue.
func OnMissing ¶
func OnMissing(callback func(c cid.Cid)) WalkOption
OnMissing is a WalkOption adding a callback that will be triggered on a missing node.
func SkipRoot ¶
func SkipRoot() WalkOption
SkipRoot is a WalkOption indicating that the root node should skipped
type Web3Response ¶
Web3Response is a response to a call to the Get method.