ipfs

package
v0.0.0-...-604993b Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: ISC Imports: 45 Imported by: 0

Documentation

Overview

Package ipfs implements fs.FS wrappers around various IPFS APIS.

Index

Constants

View Source
const IPFSID filesystem.ID = "IPFS"
View Source
const IPNSID filesystem.ID = "IPNS"
View Source
const KeyFSID filesystem.ID = "KeyFS"
View Source
const PinFSID filesystem.ID = "PinFS"

Variables

This section is empty.

Functions

func WithContext

func WithContext[
	OT generic.OptionFunc[T],
	T any,
	I contextSetter[T],
](ctx context.Context,
) OT

func WithPermissions

func WithPermissions[
	OT generic.OptionFunc[T],
	T any,
	I permissionSetter[T],
](permissions fs.FileMode,
) OT

Types

type IPFS

type IPFS struct {
	// contains filtered or unexported fields
}

func NewIPFS

func NewIPFS(core coreiface.CoreAPI, options ...IPFSOption) (*IPFS, error)

func (*IPFS) Close

func (fsys *IPFS) Close() error

func (*IPFS) ID

func (*IPFS) ID() filesystem.ID

func (*IPFS) Open

func (fsys *IPFS) Open(name string) (fs.File, error)

func (*IPFS) Stat

func (fsys *IPFS) Stat(name string) (fs.FileInfo, error)

type IPFSGuest

type IPFSGuest struct {
	APIMaddr            multiaddr.Multiaddr `json:"apiMaddr,omitempty"`
	APITimeout          time.Duration       `json:"apiTimeout,omitempty"`
	NodeCacheCount      int                 `json:"nodeCacheCount,omitempty"`
	DirectoryCacheCount int                 `json:"directoryCacheCount,omitempty"`
}

func (*IPFSGuest) GuestID

func (*IPFSGuest) GuestID() filesystem.ID

func (*IPFSGuest) MakeFS

func (ig *IPFSGuest) MakeFS() (fs.FS, error)

func (*IPFSGuest) ParseField

func (ig *IPFSGuest) ParseField(key, value string) error

func (*IPFSGuest) UnmarshalJSON

func (ig *IPFSGuest) UnmarshalJSON(b []byte) error

type IPFSOption

type IPFSOption func(*ipfsSettings) error

func WithDirectoryCacheCount

func WithDirectoryCacheCount(cacheCount int) IPFSOption

WithDirectoryCacheCount sets the number of directory entry-lists the file system will hold in its cache. If <= 0, caching of entries is disabled.

func WithNodeCacheCount

func WithNodeCacheCount(cacheCount int) IPFSOption

WithNodeCacheCount sets the number of IPLD nodes the file system will hold in its cache. If <= 0, caching of nodes is disabled.

func WithNodeTimeout

func WithNodeTimeout(duration time.Duration) IPFSOption

WithNodeTimeout sets a timeout duration to use when communicating with the IPFS API/node. If <= 0, operations will not time out, and will remain pending until the file system is closed.

type IPNS

type IPNS struct {
	// contains filtered or unexported fields
}

func NewIPNS

func NewIPNS(core coreiface.CoreAPI, ipfs fs.FS, options ...IPNSOption) (*IPNS, error)

func (*IPNS) Close

func (fsys *IPNS) Close() error

func (*IPNS) ID

func (*IPNS) ID() filesystem.ID

func (*IPNS) Open

func (fsys *IPNS) Open(name string) (fs.File, error)

func (*IPNS) Stat

func (fsys *IPNS) Stat(name string) (fs.FileInfo, error)

type IPNSGuest

type IPNSGuest struct {
	IPFSGuest
	NodeExpiry time.Duration `json:"cacheExpiry,omitempty"`
}

func (*IPNSGuest) GuestID

func (*IPNSGuest) GuestID() filesystem.ID

func (*IPNSGuest) MakeFS

func (ng *IPNSGuest) MakeFS() (fs.FS, error)

func (*IPNSGuest) ParseField

func (ng *IPNSGuest) ParseField(key, value string) error

func (*IPNSGuest) UnmarshalJSON

func (ng *IPNSGuest) UnmarshalJSON(b []byte) error

type IPNSOption

type IPNSOption func(*ipnsSettings) error

func CacheNodesFor

func CacheNodesFor(duration time.Duration) IPNSOption

CacheNodesFor sets how long a node is considered valid within the cache. After this time, the node will be refreshed during its next operation.

func WithRootCache

func WithRootCache(cacheCount int) IPNSOption

WithRootCache sets the number of root names to cache. Roots will be resolved and held in the cache until they expire or this count is exceeded. If <=0, caching of names is disabled.

type KeyFS

type KeyFS struct {
	// contains filtered or unexported fields
}

func NewKeyFS

func NewKeyFS(core coreiface.KeyAPI, options ...KeyFSOption) (*KeyFS, error)

func (*KeyFS) Close

func (ki *KeyFS) Close() error

func (*KeyFS) ID

func (*KeyFS) ID() filesystem.ID

func (*KeyFS) Open

func (kfs *KeyFS) Open(name string) (fs.File, error)

func (*KeyFS) Stat

func (kfs *KeyFS) Stat(name string) (fs.FileInfo, error)

type KeyFSGuest

type KeyFSGuest struct{ IPNSGuest }

func (*KeyFSGuest) GuestID

func (*KeyFSGuest) GuestID() filesystem.ID

func (*KeyFSGuest) MakeFS

func (kg *KeyFSGuest) MakeFS() (fs.FS, error)

type KeyFSOption

type KeyFSOption func(*KeyFS) error

func WithIPNS

func WithIPNS(ipns fs.FS) KeyFSOption

type PinFS

type PinFS struct {
	// contains filtered or unexported fields
}

func NewPinFS

func NewPinFS(pinAPI coreiface.PinAPI, options ...PinFSOption) (*PinFS, error)

func (*PinFS) Close

func (pfs *PinFS) Close() error

func (*PinFS) ID

func (*PinFS) ID() filesystem.ID

func (*PinFS) Open

func (pfs *PinFS) Open(name string) (fs.File, error)

func (*PinFS) Stat

func (pfs *PinFS) Stat(name string) (fs.FileInfo, error)

type PinFSGuest

type PinFSGuest struct {
	IPFSGuest
	CacheExpiry time.Duration `json:"cacheExpiry,omitempty"`
}

func (*PinFSGuest) GuestID

func (*PinFSGuest) GuestID() filesystem.ID

func (*PinFSGuest) MakeFS

func (pg *PinFSGuest) MakeFS() (fs.FS, error)

func (*PinFSGuest) ParseField

func (pg *PinFSGuest) ParseField(key, value string) error

func (*PinFSGuest) UnmarshalJSON

func (pg *PinFSGuest) UnmarshalJSON(b []byte) error

type PinFSOption

type PinFSOption func(*PinFS) error

func CachePinsFor

func CachePinsFor(duration time.Duration) PinFSOption

func WithIPFS

func WithIPFS(ipfs fs.FS) PinFSOption

WithIPFS supplies an IPFS instance to use for added functionality. One such case is resolving a pin's file metadata.

Jump to

Keyboard shortcuts

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