DAGService is a library for storing and replicating hash-linked data over the IPFS network.
DAGService is aiming to be a bare minimum needed for IPLD-based applications to interact with the IPFS network by getting and putting blocks to it.
NOTE For now, this is a highly experimental library. Use with caution.
This project was originally developed under the @textileio organization, and was contributed to the IPFS community for ongoing maintenance and development.
The goal of DAGService to provied a minimal layer between data model of IPLD and full blown IPFS. It provides bare minimum functionality for any application to interact with the IPFS network (by getting and putting IPLD blocks) without having to deal with the complexities of operating a full IPFS node. It is an attempt to remake core piece of IPFS node reusable on it's own.
Because 99% of the time, a browser or mobile (d)App only needs to be able to add and get small bits of data over the IPFS network. This library provides that, in a much smaller package (currently less than 1/2 the size of js-ipfs
without much optimization -- we will continue to optimize further). It is also highly extensible, so developers need only include the features they need, keeping load times fast, and (d)Apps feeling snappy. Additionally, Textile needed a Typescript-based IPFS solution, and we think others will find the type safety useful as well. Feel free to use the Typescript declarations in your own projects.
npm install dag-service
import { Peer, BlockStore } from "dag-service"
// Use any interface-datastore compliant store
import { MemoryDatastore } from "interface-datastore"
import Libp2p from "libp2p"
const store = new BlockStore(new MemoryDatastore())
const main = async () => {
// Bring your own libp2p host....
const host = new Libp2p({ ...libp2Options })
const lite = new Peer(store, host)
await lite.start()
const cid = "QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u"
const data = await lite.getFile(cid)
console.log(data.toString())
// Hello World
await lite.stop()
}
There are also several useful examples included in the tests of this repo, with tools for creating a default libp2p
host exported by default. We've also thrown in some useful interfaces to use when building on IPFS Lite, as well as the Buffer API for use in the browser.
See https://ipfs.github.io/js-dag-service/
Feel free to dive in! Open an issue or submit PRs.
To contribute to IPFS in general, see the contributing guide.
Project follows the IPFS Community Code of Conduct
The js-dag-service project is dual-licensed under Apache 2.0 and MIT terms:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)