ipfs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Overview

Package ipfs implements an interface to ipfs's codebase that also fulfills the backend.Backend interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIsOffline is returned when an online operation was done offline.
	ErrIsOffline = errors.New("Node is offline")
)

Functions

func ForwardLog added in v0.2.0

func ForwardLog(w io.Writer)

ForwardLog routes all ipfs logs to a file provided by brig.

func Init

func Init(path string, keySize int) error

Init creates an initialized .ipfs directory in the directory `path`. The generated RSA key will have `keySize` bits.

func WithIpfs

func WithIpfs(t *testing.T, f func(*Node))

WithIpfs creates a new ipfs node and passes it to `f`.

func WithIpfsAtPath

func WithIpfsAtPath(t *testing.T, root string, f func(*Node))

WithIpfsAtPath creates a new ipfs node at `path` and passes it to `f`.

func WithIpfsAtPathAndPort

func WithIpfsAtPathAndPort(t *testing.T, root string, port int, f func(*Node))

WithIpfsAtPathAndPort is the same as WithIpfs with the ability to change `port` and `path`.

func WithIpfsAtPort

func WithIpfsAtPort(t *testing.T, port int, f func(*Node))

WithIpfsAtPort is the same as WithIpfs with the ability to change `port`.

Types

type Listener

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

Listener is a ipfs net.Listener that will accecpt all incoming ipfs connections having a certain protocol.

func (*Listener) Accept

func (lst *Listener) Accept() (net.Conn, error)

Accept is like net.Listener.Accept()

func (*Listener) Addr

func (lst *Listener) Addr() net.Addr

Addr returns the listen addr of the listener.

func (*Listener) Close

func (lst *Listener) Close() error

Close will stop accepting new connections.

func (*Listener) SetDeadline

func (lst *Listener) SetDeadline(t time.Time) error

SetDeadline is not implemented.

type Node

type Node struct {
	Path      string
	SwarmPort int
	// contains filtered or unexported fields
}

Node remembers the settings needed for accessing the ipfs daemon.

func New

func New(ipfsPath string, bootstrapAddrs []string) (*Node, error)

New creates a new ipfs node manager. No daemon is started yet.

func NewWithPort

func NewWithPort(ipfsPath string, bootstrapAddrs []string, swarmPort int) (*Node, error)

NewWithPort creates a new ipfs instance with the repo at `ipfsPath` the additional bootstrap addrs in `bootstrapAddrs` at port `swarmPort`.

func (*Node) Add

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

Add reads `r` and adds it to ipfs. The resulting content hash is returned.

func (*Node) Cat

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

Cat returns an io.Reader that reads from ipfs.

func (*Node) Close

func (nd *Node) Close() error

Close shuts down the ipfs node. It may not be used afterwards.

func (*Node) Connect

func (nd *Node) Connect() error

Connect will connect to the ipfs network. This is the default anyways.

func (*Node) Dial

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

Dial connects to the repo identified by `peerHash` with the protocol `protocol`.

func (*Node) Disconnect

func (nd *Node) Disconnect() error

Disconnect disconnects from the ipfs network.

func (*Node) GC

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

GC triggers IPFS' garbage collector. It returns the hashes of the collected nodes.

func (*Node) Identity

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

Identity returns the base58 encoded id of the own ipfs node.

func (*Node) IsOnline

func (nd *Node) IsOnline() bool

IsOnline returns true when the ipfs node is online.

func (*Node) IsPinned

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

IsPinned returns true if `hash` is pinned.

func (*Node) Listen

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

Listen for all incoming connections using `protocol`.

func (*Node) Name

func (nd *Node) Name() string

Name returns "ipfs" as name of the backend.

func (*Node) Pin

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

Pin does the same as `ipfs pin add <hash>`

func (*Node) Ping

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

Ping returns a new Pinger. It can be used to query the time the remote was last seen. It will be constantly updated until close is called on it.

func (*Node) PublishName

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

PublishName makes the string `name` known in the network.

func (*Node) ResolveName

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

ResolveName finds the object pointed to by `hash`. it will wait for max `timeout` duration if it got less than `n` items in that time. if `n` is less than 0, all reachable peers that have `hash` will be returned. if `n` is 0, locate will return immeditately. this operation requires online-mode.

func (*Node) Unpin

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

Unpin does the same as `ipfs pin rm <hash>`

type Pinger

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

Pinger handles pinging over nodes on a network level.

func (*Pinger) Close

func (p *Pinger) Close() error

Close will clean up the pinger.

func (*Pinger) Err

func (p *Pinger) Err() error

Err will return a non-nil error when the current ping did not succeed.

func (*Pinger) LastSeen

func (p *Pinger) LastSeen() time.Time

LastSeen returns the time we pinged the remote last time.

func (*Pinger) Roundtrip

func (p *Pinger) Roundtrip() time.Duration

Roundtrip returns the time needed send a single package to the remote and receive the answer.

type VersionInfo added in v0.2.0

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

VersionInfo holds version info (yeah, golint)

func Version

func Version() *VersionInfo

Version returns detailed VersionInfo info as struct

func (*VersionInfo) Name added in v0.2.0

func (v *VersionInfo) Name() string

Name returns the name of the backend

func (*VersionInfo) Rev added in v0.2.0

func (v *VersionInfo) Rev() string

Rev returns the git revision of the backend

func (*VersionInfo) SemVer added in v0.2.0

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