ipfs

package
v0.0.0-...-2c2efe1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package ipfs - connect, get and set operations for embedded or external IPFS node

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNodeConnection when the ipfs node is not accessible
	ErrNodeConnection = errors.New("ipfs node connection problem")
	// ErrDocumentNotValid when the ipfs document is not well formatted
	ErrDocumentNotValid = errors.New("document not valid")
	// ErrDocumentNotFound when the ipfs document is not dound
	ErrDocumentNotFound = errors.New("document not found")
)

Functions

This section is empty.

Types

type APIConnector

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

APIConnector is IPFS Shell API Connector

func (*APIConnector) Add

func (c *APIConnector) Add(data []byte) (string, error)

Add adds a data to the IPFS network and returns the ipfs path

func (*APIConnector) AddJSON

func (c *APIConnector) AddJSON(data interface{}) (string, error)

AddJSON encodes the data in JSON and adds it to the IPFS

func (*APIConnector) Get

func (c *APIConnector) Get(path string) ([]byte, error)

Get gets a data from ipfs path

func (*APIConnector) GetID

func (c *APIConnector) GetID() string

GetID returns the local id

func (*APIConnector) GetJSON

func (c *APIConnector) GetJSON(path string, data interface{}) error

GetJSON gets data from IPFS and decodes it from JSON

type APIConnectorBuilder

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

APIConnectorBuilder for building the IPFS API connector

type APIConnectorOption

type APIConnectorOption func(*APIConnectorBuilder) error

APIConnectorOption function

func NodeAddr

func NodeAddr(addr string) APIConnectorOption

NodeAddr specifies the IPFS local node address

func PeerAddr

func PeerAddr(peerAddr string) APIConnectorOption

PeerAddr specifies the IPFS node peer to connect

func PeerDomain

func PeerDomain(domain string) APIConnectorOption

PeerDomain returns the IPFS peer addr from domain TXT record

type Connector

type Connector interface {
	GetID() string
	Add(data []byte) (string, error)
	Get(path string) ([]byte, error)
	AddJSON(data interface{}) (string, error)
	GetJSON(path string, data interface{}) error
}

Connector is the IPFS connector interface

func NewAPIConnector

func NewAPIConnector(options ...APIConnectorOption) (Connector, error)

NewAPIConnector inisialises new IPFS API connector

func NewMemoryConnector

func NewMemoryConnector() (Connector, error)

NewMemoryConnector creates a new MemoryConnector struct

func NewNodeConnector

func NewNodeConnector(options ...NodeConnectorOption) (Connector, error)

NewNodeConnector inisialises and runs a new IPFS Node

type MemoryConnector

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

MemoryConnector ipmlements IPFS Connector interface with Memory storage

func (*MemoryConnector) Add

func (m *MemoryConnector) Add(data []byte) (string, error)

Add adds data to Memory IPFS

func (*MemoryConnector) AddJSON

func (m *MemoryConnector) AddJSON(data interface{}) (string, error)

AddJSON encodes data to JSON and stores it in Memory IPFS

func (*MemoryConnector) Get

func (m *MemoryConnector) Get(path string) ([]byte, error)

Get gets data from Memory IPFS

func (*MemoryConnector) GetID

func (m *MemoryConnector) GetID() string

GetID returns the local id

func (*MemoryConnector) GetJSON

func (m *MemoryConnector) GetJSON(path string, data interface{}) error

GetJSON gets data from IPFS and decodes it from JSON

type NodeConnector

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

NodeConnector is IPFS embedded node

func (*NodeConnector) Add

func (c *NodeConnector) Add(data []byte) (string, error)

Add adds a data to the IPFS network and returns the ipfs path

func (*NodeConnector) AddJSON

func (c *NodeConnector) AddJSON(data interface{}) (string, error)

AddJSON encodes the data in JSON and adds it to the IPFS

func (*NodeConnector) Get

func (c *NodeConnector) Get(ipfsPath string) ([]byte, error)

Get gets a data from ipfs path

func (*NodeConnector) GetID

func (c *NodeConnector) GetID() string

GetID returns the local id

func (*NodeConnector) GetJSON

func (c *NodeConnector) GetJSON(path string, data interface{}) error

GetJSON gets data from IPFS and decodes it from JSON

type NodeConnectorBuilder

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

NodeConnectorBuilder for building the IPFS embedded node connector

type NodeConnectorOption

type NodeConnectorOption func(*NodeConnectorBuilder) error

NodeConnectorOption function

func AddBootstrapPeer

func AddBootstrapPeer(peerAddr ...string) NodeConnectorOption

AddBootstrapPeer adds a IPFS peer to the list of IPFS bootatrap addresses

func AddDefaultBootstrapPeers

func AddDefaultBootstrapPeers() NodeConnectorOption

AddDefaultBootstrapPeers adds the default IPFS bootstrap addresses The default IPFS addresses are maintained by the IPFS team

func AddLocalAddress

func AddLocalAddress(addr string) NodeConnectorOption

AddLocalAddress adds a new local IPFS Swarm address

func WithContext

func WithContext(ctx context.Context) NodeConnectorOption

WithContext sets the context

func WithLevelDatastore

func WithLevelDatastore(path string) NodeConnectorOption

WithLevelDatastore initialize IPFS node with LevelDB datastore

func WithMemoryDatastore

func WithMemoryDatastore() NodeConnectorOption

WithMemoryDatastore initialize IPFS node with memory datastore

Jump to

Keyboard shortcuts

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