Documentation ¶
Index ¶
- Constants
- func DefaultBootstrapPeers() []peer.AddrInfo
- func SetupLibp2p(ctx context.Context, hostKey crypto.PrivKey, listenAddrs []multiaddr.Multiaddr, ...) (host.Host, *dualdht.DHT, error)
- type AddParams
- type Adder
- type Link
- type Option
- type Options
- type Peer
- func (p *Peer) AddDir(ctx context.Context, dir string, params *AddParams) (ipld.Node, error)
- func (p *Peer) AddFile(ctx context.Context, r io.Reader, params *AddParams) (ipld.Node, error)
- func (p *Peer) BlockStore() blockstore.Blockstore
- func (p *Peer) Bootstrap(peers []peer.AddrInfo)
- func (p *Peer) Connect(ctx context.Context, pi peer.AddrInfo) error
- func (p *Peer) ConnectIfNotConnectedUsingRelay(ctx context.Context, providers []peer.ID)
- func (p *Peer) DeleteFile(ctx context.Context, c cid.Cid) error
- func (p *Peer) Disconnect(pi peer.AddrInfo) error
- func (p *Peer) Download(ctx context.Context, c cid.Cid) error
- func (p *Peer) FindProviders(ctx context.Context, id cid.Cid) []peer.ID
- func (p *Peer) GetFile(ctx context.Context, c cid.Cid) (ufsio.ReadSeekCloser, error)
- func (p *Peer) HandlePeerFound(pi peer.AddrInfo)
- func (p *Peer) HandlePeerFoundWithError(pi peer.AddrInfo) error
- func (p *Peer) HasBlock(c cid.Cid) (bool, error)
- func (p *Peer) IsOnline() bool
- func (p *Peer) Peers() []string
- func (p *Peer) Session(ctx context.Context) ipld.NodeGetter
- func (p *Peer) ZeroConfScan()
Constants ¶
const (
// ServiceTag is used for mDNS
ServiceTag = "_datahop-discovery._tcp"
)
Variables ¶
This section is empty.
Functions ¶
func DefaultBootstrapPeers ¶
DefaultBootstrapPeers returns the default datahop bootstrap peers (for use with NewLibp2pHost.
func SetupLibp2p ¶
func SetupLibp2p( ctx context.Context, hostKey crypto.PrivKey, listenAddrs []multiaddr.Multiaddr, ds datastore.Batching, opts ...libp2p.Option, ) (host.Host, *dualdht.DHT, error)
SetupLibp2p returns a routed host and DHT instances that can be used to easily create an ipfslite Peer. You may consider to use Peer.Bootstrap() or Peer.Connect() after creating the IPFS-Lite Peer to connect to other peers.
Additional libp2p options can be passed. Interesting options to pass: NATPortMap() EnableAutoRelay(), libp2p.EnableNATService(), DisableRelay(), ConnectionManager(...)... see https://godoc.org/github.com/libp2p/go-libp2p#Option for more info.
Types ¶
type AddParams ¶
type AddParams struct { Layout string Chunker string RawLeaves bool Hidden bool Shard bool NoCopy bool HashFun string }
AddParams contains all of the configurable parameters needed to specify the importing process of a file.
type Adder ¶ added in v0.0.16
type Adder struct { Out chan<- interface{} Progress bool Trickle bool RawLeaves bool Silent bool NoCopy bool Chunker string CidBuilder cid.Builder // contains filtered or unexported fields }
Adder holds the switches passed to the `add` command.
func (*Adder) SetMfsRoot ¶ added in v0.0.16
func (adder *Adder) SetMfsRoot(r *mfs.Root)
SetMfsRoot sets `r` as the root for Adder.
type Option ¶
type Option func(*Options)
Option is interface for setting up the datahop ipfslite node
func WithAutoDownload ¶ added in v0.0.16
WithAutoDownload decides if content will be downloaded automatically
func WithCrdtNamespace ¶
WithCrdtNamespace sets the replication crdt namespace
func WithCrdtTopic ¶
WithCrdtTopic sets the replication crdt listen topic
func WithRebroadcastInterval ¶
WithRebroadcastInterval changes default crdt rebroadcast interval
func WithmDNSInterval ¶
WithmDNSInterval changes default mDNS rebroadcast interval
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options for setting up the datahop ipfslite node
type Peer ¶
type Peer struct { Ctx context.Context Cancel context.CancelFunc Host host.Host Store datastore.Batching DHT routing.Routing Repo repo.Repo ipld.DAGService // become a DAG service Manager *replication.Manager Stopped chan bool CrdtTopic string // contains filtered or unexported fields }
Peer is an IPFS-Lite peer. It provides a DAG service that can fetch and put blocks from/to the IPFS network.
func New ¶
func New( ctx context.Context, cancelFunc context.CancelFunc, r repo.Repo, swarmKey []byte, opts ...Option, ) (*Peer, error)
New creates an IPFS-Lite Peer. It uses the given datastore, libp2p Host and Routing (usuall the DHT). Peer implements the ipld.DAGService interface.
func (*Peer) AddFile ¶
AddFile chunks and adds content to the DAGService from a reader. The content is stored as a UnixFS DAG (default for IPFS). It returns the root ipld.Node.
func (*Peer) BlockStore ¶
func (p *Peer) BlockStore() blockstore.Blockstore
BlockStore offers access to the blockstore underlying the Peer's DAGService.
func (*Peer) Bootstrap ¶
Bootstrap is an optional helper to connect to the given peers and bootstrap the Peer DHT (and Bitswap). This is a best-effort function. Errors are only logged and a warning is printed when less than half of the given peers could be contacted. It is fine to pass a list where some peers will not be reachable.
func (*Peer) ConnectIfNotConnectedUsingRelay ¶ added in v0.0.16
func (*Peer) DeleteFile ¶
DeleteFile removes content from blockstore by its root CID. The file must have been added as a UnixFS DAG (default for IPFS).
func (*Peer) Disconnect ¶
Disconnect host from a given peer
func (*Peer) FindProviders ¶
FindProviders check dht to check for providers of a given cid
func (*Peer) GetFile ¶
GetFile returns a reader to a file as identified by its root CID. The file must have been added as a UnixFS DAG (default for IPFS).
func (*Peer) HandlePeerFound ¶
HandlePeerFound tries to connect to a given peerinfo
func (*Peer) HandlePeerFoundWithError ¶
HandlePeerFoundWithError tries to connect to a given peerinfo, returns error if failed
func (*Peer) HasBlock ¶
HasBlock returns whether a given block is available locally. It is a shorthand for .Blockstore().Has().
func (*Peer) Session ¶
func (p *Peer) Session(ctx context.Context) ipld.NodeGetter
Session returns a session-based NodeGetter.
func (*Peer) ZeroConfScan ¶
func (p *Peer) ZeroConfScan()