Documentation ¶
Index ¶
- Variables
- func SetupLibp2p(ctx context.Context, hostKey crypto.PrivKey, listenAddrs []multiaddr.Multiaddr, ...) (host.Host, *dualdht.DHT, error)
- type Config
- type Peer
- func (p *Peer) BlockStore() bstore.Blockstore
- func (p *Peer) Bootstrap(peers []peer.AddrInfo)
- func (p *Peer) GetBlock(w auth.Want) (auth.AuthBlock, error)
- func (p *Peer) GetRefs() (<-chan cid.Cid, error)
- func (p *Peer) HasBlock(c cid.Cid) (bool, error)
- func (p *Peer) PutBlock(b blocks.Block) error
- func (p *Peer) RmBlock(c cid.Cid) error
Constants ¶
This section is empty.
Variables ¶
var Libp2pOptionsExtra = []libp2p.Option{ libp2p.NATPortMap(), libp2p.EnableAutoRelay(), libp2p.EnableNATService(), libp2p.Security(libp2ptls.ID, libp2ptls.New), libp2p.Transport(libp2pquic.NewTransport), libp2p.DefaultTransports, }
Libp2pOptionsExtra provides some useful libp2p options to create a fully featured libp2p host. It can be used with SetupLibp2p.
Functions ¶
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 a ipfsnucleus Peer. You may consider to use Peer.Bootstrap() after creating the IPFS-Nucleus Peer to connect to other peers. When the datastore parameter is nil, the DHT will use an in-memory datastore, so all provider records are lost on program shutdown.
Additional libp2p options can be passed. Note that the Identity, ListenAddrs and PrivateNetwork options will be setup automatically. 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 Config ¶
type Config struct { // ReprovideInterval sets how often to reprovide records to the DHT ReprovideInterval time.Duration }
Config wraps configuration options for the Peer.
type Peer ¶
func New ¶
func New( ctx context.Context, blockstore bstore.Blockstore, authedblockstore auth.AuthBlockstore, rootstore ds.Batching, host host.Host, dht routing.Routing, cfg *Config, ) (*Peer, error)
New creates an IPFS-Nucleus Peer. It uses the given datastore, libp2p Host and Routing (DHT). Peer implements the ipld.DAGService interface.
func (*Peer) BlockStore ¶
func (p *Peer) BlockStore() bstore.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.
Directories ¶
Path | Synopsis |
---|---|
package blockservice implements a BlockService interface that provides a single GetBlock/AddBlock interface that seamlessly retrieves data either locally or from a remote peer through the exchange.
|
package blockservice implements a BlockService interface that provides a single GetBlock/AddBlock interface that seamlessly retrieves data either locally or from a remote peer through the exchange. |