ipfsutil

package
v2.108.5 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: Apache-2.0, MIT Imports: 54 Imported by: 0

Documentation

Overview

Package ipfsutil contains helpers around IPFS (logging, datastore, networking, core API, ...).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBuildConfig added in v2.53.1

func CreateBuildConfig(repo ipfs_repo.Repo, opts *CoreAPIConfig) (*ipfs_node.BuildCfg, error)

func CreateMockedRepo added in v2.57.1

func CreateMockedRepo(dstore ipfs_ds.Batching) (ipfs_repo.Repo, error)

func EnableConnLogger added in v2.97.0

func EnableConnLogger(logger *zap.Logger, h host.Host)

func LoadRepoFromPath added in v2.57.1

func LoadRepoFromPath(path string) (ipfs_repo.Repo, error)

func NewDatastoreKeystore

func NewDatastoreKeystore(ds datastore.Datastore) keystore.Keystore

func NewNamespacedDatastore

func NewNamespacedDatastore(child ds.Datastore, prefix ds.Key) ds.Batching

func NewTinderRouting added in v2.50.0

func NewTinderRouting(logger *zap.Logger, rdvpeer *peer.AddrInfo, dhtclient bool, localDiscovery bool) (ipfs_p2p.RoutingOption, <-chan *RoutingOut)

func OptionLocalRecord added in v2.94.0

func OptionLocalRecord(ctx context.Context, node *ipfs_core.IpfsNode, api ipfs_interface.CoreAPI) error

OptionLocalRecord is given to CoreAPIOption.Options when the ipfs node setup

func OptionMDNSDiscovery

func OptionMDNSDiscovery(ctx context.Context, node *ipfs_core.IpfsNode, api ipfs_interface.CoreAPI) error

func ParseAndResolveIpfsAddr added in v2.53.1

func ParseAndResolveIpfsAddr(ctx context.Context, addr string) (*peer.AddrInfo, error)

parseIpfsAddr is a function that takes in addr string and return ipfsAddrs

func ServeHTTPApi added in v2.70.0

func ServeHTTPApi(logger *zap.Logger, node *core.IpfsNode, rootDirectory string)

ServeHTTPApi collects options, creates listener, prints status message and starts serving requests

func ServeHTTPWebui added in v2.70.0

func ServeHTTPWebui(logger *zap.Logger)

func TestingRDVP added in v2.50.0

func TestingRDVP(ctx context.Context, t testing.TB, h host.Host) (*rendezvous.RendezvousService, func())

func TestingRepo added in v2.31.1

func TestingRepo(t testing.TB) ipfs_repo.Repo

Types

type ConnMgr added in v2.70.0

type ConnMgr interface {
	TagPeer(peer.ID, string, int)
	UntagPeer(p peer.ID, tag string)
	Protect(id peer.ID, tag string)
	Unprotect(id peer.ID, tag string) (protected bool)
	GetTagInfo(p peer.ID) *connmgr.TagInfo
}

type CoreAPIConfig added in v2.53.1

type CoreAPIConfig struct {
	BootstrapAddrs []string
	SwarmAddrs     []string
	APIAddrs       []string
	APIConfig      config.API

	ExtraLibp2pOption p2p.Option
	Routing           ipfs_libp2p.RoutingOption

	Options []CoreAPIOption
}

type CoreAPIMock

type CoreAPIMock interface {
	ExtendedCoreAPI

	Tinder() tinder.Driver
	MockNetwork() libp2p_mocknet.Mocknet
	MockNode() *ipfs_core.IpfsNode
	Close()
}

CoreAPIMock implements ipfs.CoreAPI and adds some debugging helpers

func TestingCoreAPI

func TestingCoreAPI(ctx context.Context, t testing.TB) (CoreAPIMock, func())

TestingCoreAPI returns a fully initialized mocked Core API. If you want to do some tests involving multiple peers you should use `TestingCoreAPIUsingMockNet` with the same mocknet instead.

func TestingCoreAPIUsingMockNet

func TestingCoreAPIUsingMockNet(ctx context.Context, t testing.TB, opts *TestingAPIOpts) (api CoreAPIMock, cleanup func())

TestingCoreAPIUsingMockNet returns a fully initialized mocked Core API with the given mocknet

type CoreAPIOption added in v2.53.1

type DiscoveryNotifee

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

func (*DiscoveryNotifee) HandlePeerFound

func (n *DiscoveryNotifee) HandlePeerFound(pi peer.AddrInfo)

type ExtendedCoreAPI added in v2.59.0

type ExtendedCoreAPI interface {
	ipfs_interface.CoreAPI

	NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error)
	SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
	RemoveStreamHandler(pid protocol.ID)
	ConnMgr() ConnMgr
}

func NewConfigurableCoreAPI

func NewConfigurableCoreAPI(ctx context.Context, bcfg *ipfs_node.BuildCfg, opts ...CoreAPIOption) (ExtendedCoreAPI, *ipfs_core.IpfsNode, error)

NewConfigurableCoreAPI returns an IPFS CoreAPI from a provided ipfs_node.BuildCfg

func NewCoreAPI added in v2.53.1

func NewCoreAPIFromDatastore added in v2.57.1

func NewCoreAPIFromDatastore(ctx context.Context, ds ipfs_ds.Batching, cfg *CoreAPIConfig) (ExtendedCoreAPI, *ipfs_core.IpfsNode, error)

func NewCoreAPIFromRepo added in v2.57.1

func NewCoreAPIFromRepo(ctx context.Context, repo ipfs_repo.Repo, cfg *CoreAPIConfig) (ExtendedCoreAPI, *ipfs_core.IpfsNode, error)

func NewExtendedCoreAPI added in v2.59.0

func NewExtendedCoreAPI(host ipfs_host.Host, api ipfs_interface.CoreAPI) ExtendedCoreAPI

type LocalRecord added in v2.94.0

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

func (*LocalRecord) ClosedStream added in v2.94.0

func (lr *LocalRecord) ClosedStream(network.Network, network.Stream)

called when a stream closed

func (*LocalRecord) Connected added in v2.94.0

func (lr *LocalRecord) Connected(net network.Network, c network.Conn)

called when a connection opened

func (*LocalRecord) Disconnected added in v2.94.0

func (lr *LocalRecord) Disconnected(network.Network, network.Conn)

called when a connection closed

func (*LocalRecord) Listen added in v2.94.0

func (lr *LocalRecord) Listen(network.Network, ma.Multiaddr)

called when network starts listening on an addr

func (*LocalRecord) ListenClose added in v2.94.0

func (lr *LocalRecord) ListenClose(network.Network, ma.Multiaddr)

called when network stops listening on an addr

func (*LocalRecord) OpenedStream added in v2.94.0

func (lr *LocalRecord) OpenedStream(network.Network, network.Stream)

called when a stream opened

type RoutingOut added in v2.50.0

type RoutingOut struct {
	*dht.IpfsDHT
	tinder.Routing
}

type TestingAPIOpts added in v2.50.0

type TestingAPIOpts struct {
	Logger  *zap.Logger
	Mocknet libp2p_mocknet.Mocknet
	RDVPeer peer.AddrInfo
}

Jump to

Keyboard shortcuts

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