core

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2015 License: MIT Imports: 52 Imported by: 0

Documentation

Overview

package core implements the IpfsNode object and methods for constructing and properly setting it up.

Index

Constants

View Source
const IpnsValidatorTag = "ipns"

Variables

View Source
var DefaultBootstrapConfig = BootstrapConfig{
	MinPeerThreshold:  4,
	Period:            30 * time.Second,
	ConnectionTimeout: (30 * time.Second) / 3,
}

DefaultBootstrapConfig specifies default sane parameters for bootstrapping.

View Source
var ErrAlreadyBuilt = errors.New("this builder has already been used")
View Source
var ErrNotEnoughBootstrapPeers = errors.New("not enough bootstrap peers to bootstrap")

ErrNotEnoughBootstrapPeers signals that we do not have enough bootstrap peers to bootstrap correctly.

Functions

func Bootstrap

func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error)

Bootstrap kicks off IpfsNode bootstrapping. This function will periodically check the number of open connections and -- if there are too few -- initiate connections to well-known bootstrap peers. It also kicks off subsystem bootstrapping (i.e. routing).

func Resolve added in v0.3.2

func Resolve(n *IpfsNode, p path.Path) (*merkledag.Node, error)

Resolves the given path by parsing out /ipns/ entries and then going through the /ipfs/ entries and returning the final merkledage node. Effectively enables /ipns/ in CLI commands.

Types

type BootstrapConfig

type BootstrapConfig struct {

	// MinPeerThreshold governs whether to bootstrap more connections. If the
	// node has less open connections than this number, it will open connections
	// to the bootstrap nodes. From there, the routing system should be able
	// to use the connections to the bootstrap nodes to connect to even more
	// peers. Routing systems like the IpfsDHT do so in their own Bootstrap
	// process, which issues random queries to find more peers.
	MinPeerThreshold int

	// Period governs the periodic interval at which the node will
	// attempt to bootstrap. The bootstrap process is not very expensive, so
	// this threshold can afford to be small (<=30s).
	Period time.Duration

	// ConnectionTimeout determines how long to wait for a bootstrap
	// connection attempt before cancelling it.
	ConnectionTimeout time.Duration

	// BootstrapPeers is a function that returns a set of bootstrap peers
	// for the bootstrap process to use. This makes it possible for clients
	// to control the peers the process uses at any moment.
	BootstrapPeers func() []peer.PeerInfo
}

BootstrapConfig specifies parameters used in an IpfsNode's network bootstrapping process.

func BootstrapConfigWithPeers

func BootstrapConfigWithPeers(pis []peer.PeerInfo) BootstrapConfig

type ConfigOption

type ConfigOption func(ctx context.Context) (*IpfsNode, error)

func Offline

func Offline(r repo.Repo) ConfigOption

func Online

func Online(r repo.Repo) ConfigOption

func OnlineWithOptions

func OnlineWithOptions(r repo.Repo, router RoutingOption, ho HostOption) ConfigOption

func Standard

func Standard(r repo.Repo, online bool) ConfigOption

DEPRECATED: use Online, Offline functions

type DiscoveryOption added in v0.3.2

type DiscoveryOption func(p2phost.Host) (discovery.Service, error)

type HostOption

type HostOption func(ctx context.Context, id peer.ID, ps peer.Peerstore, bwr metrics.Reporter) (p2phost.Host, error)
var DefaultHostOption HostOption = constructPeerHost

type IpfsNode

type IpfsNode struct {

	// Self
	Identity peer.ID // the local node's identity

	Repo repo.Repo

	// Local node
	Pinning    pin.Pinner // the pinning manager
	Mounts     Mounts     // current mount state, if any.
	PrivateKey ic.PrivKey // the local node's private Key

	// Services
	Peerstore  peer.Peerstore       // storage for other Peer instances
	Blockstore bstore.Blockstore    // the block store (lower level)
	Blocks     *bserv.BlockService  // the block service, get/add blocks.
	DAG        merkledag.DAGService // the merkle dag service, get/add objects.
	Resolver   *path.Resolver       // the path resolution system
	Reporter   metrics.Reporter
	Discovery  discovery.Service

	// Online
	PeerHost     p2phost.Host        // the network host (server+client)
	Bootstrapper io.Closer           // the periodic bootstrapper
	Routing      routing.IpfsRouting // the routing system. recommend ipfs-dht
	Exchange     exchange.Interface  // the block exchange + strategy (bitswap)
	Namesys      namesys.NameSystem  // the name system, resolves paths to hashes
	Diagnostics  *diag.Diagnostics   // the diagnostics service
	Reprovider   *rp.Reprovider      // the value reprovider system

	IpnsFs *ipnsfs.Filesystem

	ctxgroup.ContextGroup
	// contains filtered or unexported fields
}

IpfsNode is IPFS Core module. It represents an IPFS instance.

func NewIPFSNode

func NewIPFSNode(parent context.Context, option ConfigOption) (*IpfsNode, error)

func NewMockNode

func NewMockNode() (*IpfsNode, error)

NewMockNode constructs an IpfsNode for use in tests.

func (*IpfsNode) Bootstrap

func (n *IpfsNode) Bootstrap(cfg BootstrapConfig) error

func (*IpfsNode) HandlePeerFound added in v0.3.2

func (n *IpfsNode) HandlePeerFound(p peer.PeerInfo)

func (*IpfsNode) LoadPrivateKey

func (n *IpfsNode) LoadPrivateKey() error

func (*IpfsNode) OnlineMode

func (n *IpfsNode) OnlineMode() bool

func (*IpfsNode) SetupOfflineRouting

func (n *IpfsNode) SetupOfflineRouting() error

SetupOfflineRouting loads the local nodes private key and uses it to instantiate a routing system in offline mode. This is primarily used for offline ipns modifications.

type Mounts

type Mounts struct {
	Ipfs mount.Mount
	Ipns mount.Mount
}

Mounts defines what the node's mount state is. This should perhaps be moved to the daemon or mount. It's here because it needs to be accessible across daemon requests.

type NodeBuilder

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

NodeBuilder is an object used to generate an IpfsNode

func NewNodeBuilder

func NewNodeBuilder() *NodeBuilder

func (*NodeBuilder) Build

func (nb *NodeBuilder) Build(ctx context.Context) (*IpfsNode, error)

func (*NodeBuilder) Offline

func (nb *NodeBuilder) Offline() *NodeBuilder

func (*NodeBuilder) Online

func (nb *NodeBuilder) Online() *NodeBuilder

func (*NodeBuilder) SetHost

func (nb *NodeBuilder) SetHost(ho HostOption) *NodeBuilder

func (*NodeBuilder) SetRepo

func (nb *NodeBuilder) SetRepo(r repo.Repo) *NodeBuilder

func (*NodeBuilder) SetRouting

func (nb *NodeBuilder) SetRouting(ro RoutingOption) *NodeBuilder

type RoutingOption

var DHTOption RoutingOption = constructDHTRouting

Directories

Path Synopsis
internal/incfusever
Package incfusever is only here to prevent go src tools (like godep) from thinking fuseversion is not a required package.
Package incfusever is only here to prevent go src tools (like godep) from thinking fuseversion is not a required package.

Jump to

Keyboard shortcuts

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