Back to

Package ipfs

Latest Go to latest

The latest major version is .

Published: Jan 18, 2019 | License: Apache-2.0 | Module:


Package ipfs wraps the Docker API to provide an interface through which to interact with containerized network nodes


func SwarmKey

func SwarmKey() (string, error)

SwarmKey generates a new swarm key

type Client

type Client struct {
	// contains filtered or unexported fields

Client is the primary implementation of the NodeClient interface. Instantiate using ipfs.NewClient()

func (*Client) CreateNode

func (c *Client) CreateNode(ctx context.Context, n *NodeInfo, opts NodeOpts) error

CreateNode activates a new IPFS node

func (*Client) NodeStats

func (c *Client) NodeStats(ctx context.Context, n *NodeInfo) (NodeStats, error)

NodeStats retrieves statistics about the provided node

func (*Client) Nodes

func (c *Client) Nodes(ctx context.Context) ([]*NodeInfo, error)

Nodes retrieves a list of active IPFS ndoes

func (*Client) RemoveNode

func (c *Client) RemoveNode(ctx context.Context, network string) error

RemoveNode removes assets for given node

func (*Client) StopNode

func (c *Client) StopNode(ctx context.Context, n *NodeInfo) error

StopNode shuts down an existing IPFS node

func (*Client) UpdateNode

func (c *Client) UpdateNode(ctx context.Context, n *NodeInfo) error

UpdateNode updates node configuration

func (*Client) Watch

func (c *Client) Watch(ctx context.Context) (<-chan Event, <-chan error)

Watch initializes a goroutine that tracks IPFS node events

type Event

type Event struct {
	Time   int64    `json:"time"`
	Status string   `json:"status"`
	Node   NodeInfo `json:"node"`

Event is a node-related container event

type GoIPFSConfig

type GoIPFSConfig struct {
	Identity struct {
		PeerID  string
		PrivKey string

GoIPFSConfig is a subset of go-ipfs's configuration structure

type NodeClient

type NodeClient interface {
	Nodes(ctx context.Context) (nodes []*NodeInfo, err error)
	CreateNode(ctx context.Context, n *NodeInfo, opts NodeOpts) (err error)
	UpdateNode(ctx context.Context, n *NodeInfo) (err error)
	StopNode(ctx context.Context, n *NodeInfo) (err error)
	RemoveNode(ctx context.Context, network string) (err error)
	NodeStats(ctx context.Context, n *NodeInfo) (stats NodeStats, err error)
	Watch(ctx context.Context) (<-chan Event, <-chan error)

NodeClient provides an interface to the base Docker client for controlling IPFS nodes. It is implemented by ipfs.Client

func NewClient

func NewClient(logger *zap.SugaredLogger, ipfsOpts config.IPFS) (NodeClient, error)

NewClient creates a new Docker Client from ENV values and negotiates the correct API version to use

type NodeInfo

type NodeInfo struct {
	NetworkID string `json:"network_id"`
	JobID     string `json:"job_id"`

	Ports     NodePorts     `json:"ports"`
	Resources NodeResources `json:"resources"`

	// Metadata set by node client:
	// DockerID is the ID of the node's Docker container
	DockerID string `json:"docker_id"`
	// ContainerName is the name of the node's Docker container
	ContainerName string `json:"container_id"`
	// DataDir is the path to the directory holding all data relevant to this
	// IPFS node
	DataDir string `json:"data_dir"`
	// BootstrapPeers lists the peers this node was bootstrapped onto upon init
	BootstrapPeers []string `json:"bootstrap_peers"`

NodeInfo defines metadata about an IPFS node

type NodeOpts

type NodeOpts struct {
	SwarmKey   []byte
	AutoRemove bool

NodeOpts declares options for starting up nodes

type NodePorts

type NodePorts struct {
	Swarm   string `json:"swarm"`   // default: 4001
	API     string `json:"api"`     // default: 5001
	Gateway string `json:"gateway"` // default: 8080

NodePorts declares the exposed ports of an IPFS node

type NodeResources

type NodeResources struct {
	DiskGB   int `json:"disk"`
	MemoryGB int `json:"memory"`
	CPUs     int `json:"cpus"`

NodeResources declares resource quotas for this node

type NodeStats

type NodeStats struct {
	PeerID    string
	PeerKey   string
	Uptime    time.Duration
	DiskUsage int64
	Stats     interface{}

NodeStats provides details about a node container

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier