ipfs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package ipfs assembles the IPFS pieces OrbitDB runs on: a libp2p host, gossipsub for database update announcements, and a block service whose bitswap exchange fetches entries, identities and manifests from peers.

It plays the role Helia plays for @orbitdb/core. The defaults (TCP, Noise, Yamux, gossipsub, bitswap) interoperate with a Helia node that enables the same transports.

Callers with their own libp2p stack can fill a Node by hand instead of calling New.

Index

Constants

This section is empty.

Variables

View Source
var DefaultListenAddrs = []string{"/ip4/127.0.0.1/tcp/0"}

DefaultListenAddrs is used when Options.ListenAddrs is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// Host is the libp2p host. OrbitDB registers the heads exchange
	// protocol on it.
	Host host.Host
	// PubSub carries database updates; each database is a topic.
	PubSub *pubsub.PubSub
	// Blocks stores blocks locally and fetches missing ones from peers.
	Blocks storage.BlockService
	// Pins, if set, pins the blocks OrbitDB stores.
	Pins storage.Pinner
	// contains filtered or unexported fields
}

Node is what OrbitDB needs from IPFS.

func New

func New(ctx context.Context, opts Options) (_ *Node, err error)

New starts a node.

func (*Node) AddrInfo

func (n *Node) AddrInfo() peer.AddrInfo

AddrInfo returns the node's peer id and listen addresses.

func (*Node) Close

func (n *Node) Close() error

Close stops the node.

func (*Node) Connect

func (n *Node) Connect(ctx context.Context, pi peer.AddrInfo) error

Connect dials a peer.

type Options

type Options struct {
	// ListenAddrs are the multiaddrs to listen on. Defaults to TCP on
	// 127.0.0.1 with a random port.
	ListenAddrs []string
	// PrivateKey is the peer identity key. Defaults to a new Ed25519 key.
	PrivateKey crypto.PrivKey
	// Datastore backs the blockstore and the pinner. If nil, a LevelDB
	// datastore in Repo is used, or an in-memory one when Repo is empty
	// (blocks then do not survive a restart).
	Datastore datastore.Batching
	// Repo is a directory for a persistent datastore.
	Repo string
	// Libp2pOptions are appended to the host options.
	Libp2pOptions []libp2p.Option
	// PubSubOptions are appended to the gossipsub options.
	PubSubOptions []pubsub.Option
}

Options configures New.

Jump to

Keyboard shortcuts

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