ipfshttp

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package ipfshttp implements an IPFS Cluster IPFSConnector component. It uses the IPFS HTTP API to communicate to IPFS.

Index

Constants

This section is empty.

Variables

View Source
var (
	// maximum duration before timing out read of the request
	IPFSProxyServerReadTimeout = 5 * time.Second
	// maximum duration before timing out write of the response
	IPFSProxyServerWriteTimeout = 10 * time.Second
	// server-side the amount of time a Keep-Alive connection will be
	// kept idle before being reused
	IPFSProxyServerIdleTimeout = 60 * time.Second
)

IPFS Proxy settings

View Source
var ConnectSwarmsDelay = 7 * time.Second

ConnectSwarmsDelay specifies how long to wait after startup before attempting to open connections from this peer's IPFS daemon to the IPFS daemons of other peers.

Functions

This section is empty.

Types

type Connector

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

Connector implements the IPFSConnector interface and provides a component which does two tasks:

On one side, it proxies HTTP requests to the configured IPFS daemon. It is able to intercept these requests though, and perform extra operations on them.

On the other side, it is used to perform on-demand requests against the configured IPFS daemom (such as a pin request).

func NewConnector

func NewConnector(ipfsNodeMAddr ma.Multiaddr, ipfsProxyMAddr ma.Multiaddr) (*Connector, error)

NewConnector creates the component and leaves it ready to be started

func (*Connector) ConfigKey

func (ipfs *Connector) ConfigKey(keypath string) (interface{}, error)

ConfigKey fetches the IPFS daemon configuration and retrieves the value for a given configuration key. For example, "Datastore/StorageMax" will return the value for StorageMax in the Datastore configuration object.

func (*Connector) ConnectSwarms

func (ipfs *Connector) ConnectSwarms() error

ConnectSwarms requests the ipfs addresses of other peers and triggers ipfs swarm connect requests

func (*Connector) ID

func (ipfs *Connector) ID() (api.IPFSID, error)

ID performs an ID request against the configured IPFS daemon. It returns the fetched information. If the request fails, or the parsing fails, it returns an error and an empty IPFSID which also contains the error message.

func (*Connector) Pin

func (ipfs *Connector) Pin(hash *cid.Cid) error

Pin performs a pin request against the configured IPFS daemon.

func (*Connector) PinLs

func (ipfs *Connector) PinLs(typeFilter string) (map[string]api.IPFSPinStatus, error)

PinLs performs a "pin ls --type typeFilter" request against the configured IPFS daemon and returns a map of cid strings and their status.

func (*Connector) PinLsCid

func (ipfs *Connector) PinLsCid(hash *cid.Cid) (api.IPFSPinStatus, error)

PinLsCid performs a "pin ls --type=recursive <hash> "request and returns an api.IPFSPinStatus for that hash.

func (*Connector) RepoSize

func (ipfs *Connector) RepoSize() (int, error)

RepoSize returns the current repository size of the ipfs daemon as provided by "repo stats". The value is in bytes.

func (*Connector) SetClient

func (ipfs *Connector) SetClient(c *rpc.Client)

SetClient makes the component ready to perform RPC requests.

func (*Connector) Shutdown

func (ipfs *Connector) Shutdown() error

Shutdown stops any listeners and stops the component from taking any requests.

func (*Connector) Unpin

func (ipfs *Connector) Unpin(hash *cid.Cid) error

Unpin performs an unpin request against the configured IPFS daemon.

Jump to

Keyboard shortcuts

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