package module
Version: v0.0.11 Latest Latest

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

Go to latest
Published: Aug 15, 2022 License: BSD-3-Clause Imports: 29 Imported by: 0




View Source
const DefaultGetPathPattern = "/ipfs/%s"
View Source
const DefaultPollWait time.Duration = time.Second / 2

DefaultPollWait is the time waited between requests for a pin's status. Its default value is the duration used by go-ipfs for the `ipfs pin remote add` command


View Source
var (
	DwebLink       = GatewayURL{Base: "", SubDomainPattern: "", API: true}
	IPFSIo         = GatewayURL{Base: "", API: true}
	CloudflareIPFS = GatewayURL{Base: ""}
	InfuraIPFSIo   = GatewayURL{Base: "", SubDomainPattern: ""}
	PinataCloud    = GatewayURL{Base: "", API: true}
	EstuaryTech    = GatewayURL{Base: ""}
View Source
var DefaultLinkGateway = DwebLink
View Source
var DefaultPinTimeout = time.Minute * 5
View Source
var DefaultVerifier = func(ctx context.Context, bg retrieve.BlockGetter, c cid.Cid, rsa readerSeekerAt) (int64, error) {
	v := NewCIDVerifier(bg)
	return v.ExpectedSize(), v.Verify(ctx, c, rsa)
View Source
var ErrCantPin = errors.New("client doesn't have access to the PSA endpoint")
View Source
var ErrUnprepared = errors.New("method called on unprepared remote")
View Source
var KeyPat = regexp.MustCompile(`^(?P<backend>[A-Z\d]+[^E])(?P<ext>E)?(-s(?P<size>\d+))?(-m(?P<mtime>\d+))?(-S(?P<chunkSize>\d+)-C(?P<chunkNum>\d+))?--(?P<name>[^/\n]+)$`)


func DefaultRetriever added in v0.0.11

func DefaultRetriever(ua *http.Client) *retrieve.R

func NewCIDVerifier

func NewCIDVerifier(bg blockGetter) *cidVerifier


type AI added in v0.0.11

type AI struct {
	I           IPFSRemote
	R           *retrieve.R
	UA          *http.Client
	LinkGateway GatewayURL
	Prep        Preparer
	PinTimeout  time.Duration
	// contains filtered or unexported fields

func (*AI) Extensions added in v0.0.11

func (ai *AI) Extensions(a remote.Annex, want []string) []string

func (*AI) Init added in v0.0.11

func (ai *AI) Init(a remote.Annex) error

func (*AI) ListConfigs added in v0.0.11

func (ai *AI) ListConfigs(a remote.Annex) (css []remote.ConfigSetting)

func (*AI) Prepare added in v0.0.11

func (ai *AI) Prepare(a remote.Annex) error

Prepare creates the IPFSRemote used in most of the other exported methods. If called more than once, it will merely return a nil error.

func (*AI) Present added in v0.0.11

func (ai *AI) Present(a remote.Annex, key string) (bool, error)

TODO: Should we use SetURLPresent/SetURLMissing here?

func (*AI) Remove added in v0.0.11

func (ai *AI) Remove(a remote.Annex, key string) error

func (*AI) Retrieve added in v0.0.11

func (ai *AI) Retrieve(a remote.Annex, key, file string) error

Retrieve attempts to downloads the content stored for _key_ into _file_. It can be called even if Prepare() hasn't been called.

func (*AI) Store added in v0.0.11

func (ai *AI) Store(a remote.Annex, key, file string) error

type Gateway

type Gateway struct {
	URL GatewayURL
	UA  *http.Client

func (*Gateway) Get

func (gw *Gateway) Get(ctx context.Context, c cid.Cid, pos int64) (io.ReadCloser, error)

func (*Gateway) GetBlock

func (gw *Gateway) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error)

func (*Gateway) String

func (gw *Gateway) String() string

type GatewayURL

type GatewayURL struct {
	Base             string
	SubDomainPattern string
	API              bool

func (GatewayURL) Block

func (gu GatewayURL) Block(c cid.Cid) string

func (GatewayURL) Public

func (gu GatewayURL) Public(c cid.Cid) string

type IPFSRemote

type IPFSRemote interface {
	Upload(context.Context, fs.File, *progress.Tracker) (cid.Cid, error)
	IsPresent(context.Context, cid.Cid) (bool, error)
	Unpin(context.Context, cid.Cid) error
	Pin(context.Context, cid.Cid, string) error

type Key added in v0.0.11

type Key struct {
	Backend   string
	HasExt    bool
	Size      int64
	Mtime     int64
	ChunkSize int64
	ChunkNum  int64
	Name      string

func Decode added in v0.0.11

func Decode(key string) (Key, error)

type LocalNode

type LocalNode struct {

func (*LocalNode) Get

func (ln *LocalNode) Get(ctx context.Context, c cid.Cid, pos int64) (io.ReadCloser, error)

func (*LocalNode) IsTrusted added in v0.0.11

func (ln *LocalNode) IsTrusted() bool

IsTrusted: implements retrieve.IsTrusteder

func (*LocalNode) String

func (ln *LocalNode) String() string

type Preparer

type Preparer interface {
	Prepare(remote.Annex, *http.Client) (IPFSRemote, error)

type RemotePinner

type RemotePinner struct {
	// PollWait is the time Pin waits before polling for a status change. If nil it is equal to DefaultPollWait.
	PollWait *time.Duration
	// contains filtered or unexported fields

RemotePinner is a client for the IPFS Pinning Service API which implements the methods necessary for a Git Annex remote.

This API is specified in

func NewRemotePinner

func NewRemotePinner(endpoint, jwt string, ua *http.Client) *RemotePinner

func (*RemotePinner) IsPinned

func (rp *RemotePinner) IsPinned(ctx context.Context, c cid.Cid) (bool, error)

IsPinned returns true if the given CID has a pinned status, false if the CID has another status or is not known to the endpoint. A non-nil error is returned if there was a problem communicating with the endpoint.

func (*RemotePinner) Pin

func (rp *RemotePinner) Pin(ctx context.Context, c cid.Cid, key string) error

Pin requests that the remote pinning service pin the given CID, then waits for confirmation that the pin has been created, the pin couldn't be created, or an error occurred while communicating with the service. Where possible, the pin is named with the given Git Annex key. To impose a timeout on this operation or otherwise abort it prematurely, cancel the supplied context. In the absence of a time-limited Context this method could block indefinitely if the remote service misbehaves or is unable to retrieve the CID.

See for background on how the pin status changes. Note that we treat an unknown status as pending.

func (*RemotePinner) Unpin

func (rp *RemotePinner) Unpin(ctx context.Context, c cid.Cid) error

Unpin removes all pins for the given CID on the remote pinning service

The Pinning Service API permits multiple pins to exist for a single CID, and has no facility to remove them in bulk, so the run time of this method is proportional to the number of pins.

This method attempts to remove all pins, regardless of their status. That is, pins that are in the pinning, queued, or failed states will be deleted along with pins in the pinned state. TODO: Use metadata to only delete pins made for this repo

type Transport

type Transport struct {

func NewTransport

func NewTransport() *Transport


Path Synopsis
estuary allows Git Annex remotes to work with the Estuary service
estuary allows Git Annex remotes to work with the Estuary service
Package w3s provides a client to interact with the API in the context of Git Annex remotes.
Package w3s provides a client to interact with the API in the context of Git Annex remotes.

Jump to

Keyboard shortcuts

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