package module
v0.0.10 Latest Latest

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

Go to latest
Published: Jul 7, 2022 License: BSD-3-Clause Imports: 25 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}
View Source
var DefaultLinkGateway = DwebLink
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")


func NewCIDVerifier

func NewCIDVerifier(bg blockGetter) *cidVerifier


type Gateway

type Gateway struct {
	URL      GatewayURL
	UA       *http.Client
	Verifier blockGetter

func (*Gateway) Get

func (gw *Gateway) Get(ctx context.Context, c cid.Cid, fi readWriteSeekerAt) error

TODO: errors that allow distinguishing between get/verification failure

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 Getter

type Getter interface {
	Get(context.Context, cid.Cid, readWriteSeekerAt) error

type IA

type IA struct {
	I IPFSRemote

	UA          *http.Client
	LinkGateway GatewayURL
	Prep        Preparer
	// contains filtered or unexported fields

func (*IA) Extensions

func (ia *IA) Extensions(a remote.Annex, want []string) []string

func (*IA) Init

func (ia *IA) Init(a remote.Annex) error

func (*IA) ListConfigs

func (ia *IA) ListConfigs(a remote.Annex) (css []remote.ConfigSetting)

func (*IA) Prepare

func (ia *IA) 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 (*IA) Present

func (ia *IA) Present(a remote.Annex, key string) (bool, error)

TODO: Should we use SetURLPresent/SetURLMissing here?

func (*IA) Remove

func (ia *IA) Remove(a remote.Annex, key string) error

func (*IA) Retrieve

func (ia *IA) 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 (*IA) Store

func (ia *IA) Store(a remote.Annex, key, file string) error

type IPFSRemote

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

type LocalNode

type LocalNode struct {

func (*LocalNode) Get

func (ln *LocalNode) Get(ctx context.Context, c cid.Cid, ws readWriteSeekerAt) error

func (*LocalNode) String

func (ln *LocalNode) String() string

type Preparer

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

type Progress

type Progress struct {
	FileSize int64
	Fn       func(int64)

	TotalReported int64
	Err           error
	IsClosed      bool
	// contains filtered or unexported fields

func NewProgress

func NewProgress(fn func(int64), fileSize int64) *Progress

func (*Progress) Close

func (pr *Progress) Close() error

func (*Progress) NewReader

func (pr *Progress) NewReader(orig io.Reader) io.ReadCloser

func (*Progress) SetOverhead

func (pro *Progress) SetOverhead(over int64)

type ProgressReader

type ProgressReader struct {

func (*ProgressReader) Close

func (pr *ProgressReader) Close() error

func (*ProgressReader) Read

func (pr *ProgressReader) Read(p []byte) (int, error)

TODO: If TotalReported is set before we start reading, report that figure before the first read.

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