ipfs

package
v0.0.0-...-52bbd4c Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: GPL-3.0 Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IIpfs

type IIpfs interface {
	ID() (*ipfsapi.IdOutput, error)
	PubSubPublish(topic string, data string) error
	PubSubSubscribe(topic string) (IPubSubSubscription, error)
	Get(hash string, outdir string) error
	AddDir(dir string) (string, error)
	Publish(node string, value string) error
	Add(r io.Reader) (string, error)
	P2PListen(ctx context.Context, protocol, maddr string) (*P2PListener, error)
	P2PCloseListener(ctx context.Context, protocol string, closeAll bool) error
	P2PStreamDial(ctx context.Context, peerID, protocol, listenerMaddr string) (*P2PStream, error)
	P2PCloseStream(ctx context.Context, handlerID string, closeAll bool) error
}

IIpfs is an interface to IPFS. It is done this way to be able to mock IPFS in unit tests later

type IPubSubSubscription

type IPubSubSubscription interface {
	Cancel() error
	Next() (*ipfsapi.Message, error)
}

IPubSubSubscription is an interface to IPFS pubsub subscriptions

type Ipfs

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

Ipfs is implementation of IIpfs

func NewIpfs

func NewIpfs(url string) *Ipfs

NewIpfs creates a new IPFS instance

func (*Ipfs) Add

func (ipfs *Ipfs) Add(r io.Reader) (string, error)

Add adds a file to IPFS

func (*Ipfs) AddDir

func (ipfs *Ipfs) AddDir(dir string) (string, error)

AddDir adds a whole directory to ipfs

func (*Ipfs) Get

func (ipfs *Ipfs) Get(hash string, outdir string) error

Get gets a file from ipfs

func (*Ipfs) ID

func (ipfs *Ipfs) ID() (*ipfsapi.IdOutput, error)

ID returns the IPFS id

func (*Ipfs) P2PCloseListener

func (ipfs *Ipfs) P2PCloseListener(ctx context.Context, protocol string, closeAll bool) error

P2PCloseListener closes an open P2P listener

func (*Ipfs) P2PCloseStream

func (ipfs *Ipfs) P2PCloseStream(ctx context.Context, handlerID string, closeAll bool) error

P2PCloseStream closes an open libp2p stream

func (*Ipfs) P2PListen

func (ipfs *Ipfs) P2PListen(ctx context.Context, protocol, maddr string) (*P2PListener, error)

P2PListen will listen on the given multiaddress for libp2p connections

func (*Ipfs) P2PStreamDial

func (ipfs *Ipfs) P2PStreamDial(ctx context.Context, peerID, protocol, listenerMaddr string) (*P2PStream, error)

P2PStreamDial dials to the given IPFS id and forwards the message to the listener multiaddress

func (*Ipfs) PubSubPublish

func (ipfs *Ipfs) PubSubPublish(topic string, data string) error

PubSubPublish publishes a message in the given topic

func (*Ipfs) PubSubSubscribe

func (ipfs *Ipfs) PubSubSubscribe(topic string) (IPubSubSubscription, error)

PubSubSubscribe subscribes to a topic on IPFS pubsub

func (*Ipfs) Publish

func (ipfs *Ipfs) Publish(node string, value string) error

Publish publishes to IPNS

type P2PListener

type P2PListener struct {
	Protocol string
	Address  string
}

P2PListener is a struct for storing the results of IPFS p2p listen

type P2PStream

type P2PStream struct {
	Protocol string
	Address  string
}

P2PStream is a struct for storing the results of IPFS p2p stream dial...

type PubSubSubscription

type PubSubSubscription ipfsapi.PubSubSubscription

PubSubSubscription is an own version of PubSubSubscription

func (*PubSubSubscription) Cancel

func (sub *PubSubSubscription) Cancel() error

Cancel cancels a pubsub subscription

func (*PubSubSubscription) Next

func (sub *PubSubSubscription) Next() (*ipfsapi.Message, error)

Next reads the next message in the subscription

Jump to

Keyboard shortcuts

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