w3s

package
v0.0.0-...-e1789b5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PinStatusPinned    = PinStatus(TrackerStatusPinned)
	PinStatusPinning   = PinStatus(TrackerStatusPinning)
	PinStatusPinQueued = PinStatus(TrackerStatusPinQueued)
	PinStatusRemote    = PinStatus(TrackerStatusRemote)
	PinStatusUnpinned  = PinStatus(TrackerStatusUnpinned)
	PinStatusUnknown   = PinStatus(-1)
)

Variables

View Source
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 DefaultWalkFunc

func DefaultWalkFunc(nd format.Node) ([]*format.Link, error)

func HeaderSize

func HeaderSize(h *CarHeader) (uint64, error)

func LdRead

func LdRead(r *bufio.Reader) ([]byte, error)

func LdSize

func LdSize(d ...[]byte) uint64

func LdWrite

func LdWrite(w io.Writer, d ...[]byte) error

func ReadCid deprecated

func ReadCid(buf []byte) (cid.Cid, int, error)

Deprecated: ReadCid shouldn't be used directly, use CidFromReader from go-cid

func ReadNode

func ReadNode(br *bufio.Reader) (cid.Cid, []byte, error)

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

func WriteHeader

func WriteHeader(h *CarHeader, w io.Writer) error

Types

type BytesReader

type BytesReader interface {
	io.Reader
	io.ByteReader
}

type CarHeader

type CarHeader struct {
	Roots   []cid.Cid
	Version uint64
}

func LoadCar

func LoadCar(ctx context.Context, s Store, r io.Reader) (*CarHeader, error)

func ReadHeader

func ReadHeader(br *bufio.Reader) (*CarHeader, error)

type CarReader

type CarReader struct {
	Header *CarHeader
	// contains filtered or unexported fields
}

func NewCarReader

func NewCarReader(r io.Reader) (*CarReader, error)

func (*CarReader) Next

func (cr *CarReader) Next() (blocks.Block, error)

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.

func NewClient

func NewClient(options ...Option) (Client, error)

NewClient creates a new web3.storage API client.

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

func (d *Deal) UnmarshalJSON(b []byte) error

type DealStatus

type DealStatus int
const (
	DealStatusQueued DealStatus = iota
	DealStatusPublished
	DealStatusActive
)

func (DealStatus) String

func (s DealStatus) String() string
type GetLinks func(context.Context, cid.Cid) ([]*format.Link, error)

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

func WithEndpoint(endpoint string) Option

WithEndpoint sets the URL of the root API when making requests (default https://api.web3.storage).

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

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.

func WithToken

func WithToken(token string) Option

WithToken sets the auth token to use in the Authorization header when making requests to the API.

type Pin

type Pin struct {
	PeerID   peer.ID
	PeerName string
	Region   string
	Status   PinStatus
	Updated  time.Time
}

func (*Pin) UnmarshalJSON

func (p *Pin) UnmarshalJSON(b []byte) error

type PinOption

type PinOption func(cfg *pinConfig) error

PinOption is an option configuring a call to Pin.

func WithPinMeta

func WithPinMeta(key, value string) PinOption

WithPinMeta adds metadata about pinned data.

func WithPinName

func WithPinName(name string) PinOption

WithPinName sets the name to use for the pinned data.

func WithPinOrigin

func WithPinOrigin(ma string) PinOption

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 PinStatus

type PinStatus int

func (PinStatus) String

func (s PinStatus) String() string

type PutOption

type PutOption func(cfg *putConfig) error

PutOption is an option configuring a call to Put.

func WithDirname

func WithDirname(dirname string) PutOption

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).

func WithFs

func WithFs(fsys fs.FS) PutOption

WithFs sets the file system interface for use with file operations.

type ReadStore

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

type Status

type Status struct {
	Cid     cid.Cid
	DagSize uint64
	Created time.Time
	Pins    []Pin
	Deals   []Deal
}

Status is IPFS pin and Filecoin deal status for a given CID.

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(b []byte) error

type Store

type Store interface {
	Put(context.Context, blocks.Block) error
}

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 WalkFunc

type WalkFunc func(format.Node) ([]*format.Link, error)

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

type Web3Response struct {
	*http.Response
}

Web3Response is a response to a call to the Get method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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