httpipfs

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOffline is returned by operations that need online support
	// to work when the backend is in offline mode.
	ErrOffline = errors.New("backend is in offline mode")
)
View Source
var ErrWaiting = errors.New("waiting for route")

ErrWaiting is the initial error state of a pinger. The error will be unset once a successful ping was made.

Functions

func Init

func Init(path string) error

Init will create the folder structure for anything that needs to be persisted in the repository.

func WithDoubleIpfs

func WithDoubleIpfs(t *testing.T, portOff int, fn func(t *testing.T, ipfsPathA, ipfsPathB string))

WithDoubleIpfs starts two IPFS instances in parallel.

func WithIpfs

func WithIpfs(t *testing.T, portOff int, fn func(t *testing.T, ipfsPath string))

WithIpfs starts a new IPFS instance and calls `fn` with the API port to it. `portOff` is the offset to add on all standard ports.

Types

type Node

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

Node is the struct that holds the httpipfs backend together. It is a shallow type that has not much own state and is very light.

func NewNode

func NewNode(ipfsPath, fingerprint string) (*Node, error)

NewNode returns a new http based IPFS backend.

func (*Node) Add

func (nd *Node) Add(r io.Reader) (h.Hash, error)

Add puts the contents of `r` into IPFS and returns its hash.

func (*Node) Cat

func (nd *Node) Cat(hash h.Hash) (mio.Stream, error)

Cat returns a stream associated with `hash`.

func (*Node) Close

func (nd *Node) Close() error

Close implements Backend.Close

func (*Node) Connect

func (nd *Node) Connect() error

Connect implements Backend.Connect

func (*Node) Dial

func (nd *Node) Dial(peerHash, fingerprint, protocol string) (net.Conn, error)

Dial will open a connection to the peer identified by `peerHash`, running `protocol` over it.

func (*Node) Disconnect

func (nd *Node) Disconnect() error

Disconnect implements Backend.Disconnect

func (*Node) GC

func (nd *Node) GC() ([]h.Hash, error)

GC will trigger the garbage collector of IPFS. Cleaned up hashes will be returned as a list (note that those hashes are not always ours)

func (*Node) Identity

func (nd *Node) Identity() (peer.Info, error)

Identity returns our own identity. It will cache the identity after the first request.

func (*Node) IsCached added in v0.4.1

func (nd *Node) IsCached(hash h.Hash) (bool, error)

func (*Node) IsOnline

func (nd *Node) IsOnline() bool

IsOnline returns true if the node is in online mode and the daemon is reachable.

func (*Node) IsPinned

func (nd *Node) IsPinned(hash h.Hash) (bool, error)

IsPinned returns true when `hash` is pinned in some way.

func (*Node) Listen

func (nd *Node) Listen(protocol string) (net.Listener, error)

Listen will listen to the protocol

func (*Node) Name

func (nd *Node) Name() string

Name returns "httpipfs" as name of the backend.

func (*Node) Pin

func (nd *Node) Pin(hash h.Hash) error

Pin will pin `hash`.

func (*Node) Ping

func (nd *Node) Ping(addr string) (netBackend.Pinger, error)

Ping will return a pinger for `addr`.

func (*Node) PublishEvent

func (nd *Node) PublishEvent(topic string, data []byte) error

PublishEvent will publish `data` on `topic`.

func (*Node) PublishName

func (nd *Node) PublishName(name string) error

PublishName will announce `name` to the network and make us discoverable.

func (*Node) ResolveName

func (nd *Node) ResolveName(ctx context.Context, name string) ([]peer.Info, error)

ResolveName will return all peers that identify themselves as `name`. If ctx is canceled it will return early, but return no error.

func (*Node) Subscribe

func (nd *Node) Subscribe(ctx context.Context, topic string) (eventsBackend.Subscription, error)

Subscribe will create a subscription for `topic`. You can use the subscription to wait for the next incoming message. This will only work if the daemon supports/has enabled pub sub.

func (*Node) Unpin

func (nd *Node) Unpin(hash h.Hash) error

Unpin will unpin `hash`.

func (*Node) Version

func (n *Node) Version() *VersionInfo

Version returns detailed VersionInfo info as struct

type VersionInfo

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

VersionInfo holds version info (yeah, golint)

func (*VersionInfo) Name

func (v *VersionInfo) Name() string

Name returns the name of the backend

func (*VersionInfo) Rev

func (v *VersionInfo) Rev() string

Rev returns the git revision of the backend

func (*VersionInfo) SemVer

func (v *VersionInfo) SemVer() string

SemVer returns a VersionInfo string complying semantic versioning

Jump to

Keyboard shortcuts

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