backend

package
v0.0.0-...-e065fbe Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package backend interfaces with the Go IPFS API and enables pubsub for Scribe data. Inspiration taken from https://github.com/sahib/brig and https://github.com/planet-ethereum/relay-network

Package backend interfaces with the Go IPFS API and enables pubsub for Scribe data. Inspiration taken from https://github.com/sahib/brig and https://github.com/planet-ethereum/relay-network

Package backend interfaces with the Go IPFS API and enables pubsub for Scribe data. Inspiration taken from https://github.com/sahib/brig and https://github.com/planet-ethereum/relay-network

Package backend interfaces with the Go IPFS API and enables pubsub for Scribe data. Inspiration taken from https://github.com/sahib/brig and https://github.com/planet-ethereum/relay-network

Package backend interfaces with the Go IPFS API and enables pubsub for Scribe data. Inspiration taken from https://github.com/sahib/brig and https://github.com/planet-ethereum/relay-network

Index

Constants

View Source
const MultiHash string = "sha2-256"

MultiHash is the multihash type used by IPFS

Variables

View Source
var (
	// ErrOffline is returned by operations that need online support to work when a node is offline
	ErrOffline   = errors.New("node is offline")
	ErrNoProject = errors.New("node has no registered project")
)

error messages

Functions

func ConfigureDaemon

func ConfigureDaemon(conf *config.ScribeConfig) error

ConfigureDaemon will configure the IPFS daemon

func GetAPI

func GetAPI() string

GetAPI returns the API address the daemon will serve the API from

func LaunchDaemon

func LaunchDaemon(conf *config.ScribeConfig) error

LaunchDaemon will attempt to launch the IPFS daemon NOTE: daemon is left running and must be terminated by user

func WithIpfs

func WithIpfs(t *testing.T, portOff int, fn func(t *testing.T, APIaddress 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 {
	sync.Mutex
	// contains filtered or unexported fields
}

Node wraps the IPFS shell

func InitNode

func InitNode(ipfsAPIendpoint string) (*Node, error)

InitNode will returns a HTTP based IPFS node

func (*Node) Add

func (node *Node) Add(content []byte, pin bool) (string, error)

Add will add the content to the IPFS, pinning it if instructed

func (*Node) Cat

func (node *Node) Cat(cid string) ([]byte, error)

Cat will return the data for a given CID in the IPFS

func (*Node) Connect

func (node *Node) Connect() error

Connect allows the node to connect to the network

func (*Node) DagGet

func (node *Node) DagGet(cid, field string, output interface{}) error

DagGet wraps the DagGet API call

func (*Node) DagPut

func (node *Node) DagPut(data []byte, encoding, format string, pin bool) (string, error)

DagPut wraps the DagPut API call

func (*Node) Disconnect

func (node *Node) Disconnect() error

Disconnect prevents the node from connecting to the network

func (*Node) GetProject

func (node *Node) GetProject() string

GetProject will return the registered project for the node

func (*Node) Identity

func (node *Node) Identity() (ipfs.PeerInfo, error)

Identity gets the node's identity. It will cache the identity after the initial request

func (*Node) IsOnline

func (node *Node) IsOnline() bool

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

func (*Node) Listen

func (node *Node) Listen(msgChan chan *ipfs.Message, errChan chan error, sigChan chan struct{})

Listen will wait for messages on the PubSub subscription

msgChan is to send back received messages to the caller errChan is to send back any errors to the the caller sigChan is to terminate the listener

func (*Node) Publish

func (node *Node) Publish(message string) error

Publish will publish a message about the registered project

func (*Node) PublishName

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

PublishName will announce `name` to the network and make the node discoverable

func (*Node) SetProject

func (node *Node) SetProject(project string)

SetProject will register the node with a project

func (*Node) Subscribe

func (node *Node) Subscribe(ctx context.Context, project string) error

Subscribe will subscribe the node to a project

func (*Node) Unsubscribe

func (node *Node) Unsubscribe() error

Unsubscribe will unsubscribe the node

Jump to

Keyboard shortcuts

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