Documentation
¶
Overview ¶
Package ipfslite is a lightweight IPFS peer which runs the minimal setup to provide an `ipld.DAGService`, "Add" and "Get" UnixFS files from IPFS.
Index ¶
- func BadgerDatastore(path string) (datastore.Batching, error)
- func DefaultBootstrapPeers() []peerstore.PeerInfo
- func IPFSBadgerDatastore() (datastore.Batching, error)
- func SetupLibp2p(ctx context.Context, hostKey crypto.PrivKey, secret []byte, ...) (host.Host, *dht.IpfsDHT, error)
- type AddParams
- type Config
- type Peer
- 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 []peerstore.PeerInfo)
- func (p *Peer) GetFile(ctx context.Context, c cid.Cid) (ufsio.ReadSeekCloser, error)
- func (p *Peer) HasBlock(c cid.Cid) (bool, error)
- func (p *Peer) Session(ctx context.Context) ipld.NodeGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadgerDatastore ¶
BadgerDatastore returns a new instance of Badger-DS persisting to the given path with the default options.
func DefaultBootstrapPeers ¶
DefaultBootstrapPeers returns the default go-ipfs bootstrap peers (for use with NewLibp2pHost.
func IPFSBadgerDatastore ¶
IPFSBadgerDatastore returns the Badger datastore used by the IPFS daemon (from `~/.ipfs/datastore`). Do not use the default datastore when the regular IFPS daemon is running at the same time.
func SetupLibp2p ¶
func SetupLibp2p( ctx context.Context, hostKey crypto.PrivKey, secret []byte, listenAddrs []multiaddr.Multiaddr, ) (host.Host, *dht.IpfsDHT, error)
SetupLibp2p returns a routed host and DHT instances that can be used to easily create a ipfslite Peer. The DHT is NOT bootstrapped. You may consider to use Peer.Bootstrap() after creating the IPFS-Lite Peer.
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 Config ¶
type Config struct {
// The DAGService will not announce or retrieve blocks from the network
Offline bool
}
Config wraps configuration options for the Peer.
type Peer ¶
type Peer struct {
ipld.DAGService
// 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, store datastore.Batching, host host.Host, dht *dht.IpfsDHT, cfg *Config, ) (*Peer, error)
New creates an IPFS-Lite Peer. It uses the given datastore, libp2p Host and DHT. The Host and the DHT may be nil if config.Offline is set to true, as they are not used in that case. 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) 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).