Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ipfs-block-service

ipfs5.8kMITdeprecated0.19.1TypeScript support: included

This module has been merged into ipfs

JavaScript Implementation of BlockService

IPFS

readme

⛔️ DEPRECATED: This module has been merged into ipfs

IPFS Block Service

standard-readme compliant Travis CI Dependency Status js-standard-style

IPFS implementation of the BlockService and Block data structure in JavaScript.

BlockService - A BlockService is a content-addressable store for blocks, providing an API for adding, deleting, and retrieving blocks. A BlockService is backed by an IPFS Repo as its datastore for blocks, and uses Bitswap to fetch blocks from the network.

┌───────────────────┐
│    BlockService   │
└───────────────────┘
     ┌─────┴─────┐
     ▼           ▼
┌─────────┐ ┌───────┐
│IPFS Repo│ |Bitswap│
└─────────┘ └───────┘

Lead Maintainer

Volker Mische

Table of Contents

Install

npm

> npm install ipfs-block-service

Usage

Node.js

const BlockService = require('ipfs-block-service')

Example

const BlockService = require('ipfs-block-service')
const Block = require('ipld-block')
const multihashing = require('multihashing-async')
const IPFSRepo = require('ipfs-repo')  // storage repo
const uint8ArrayEquals = require('uint8arrays/equals')
const uint8ArrayFromString = require('uint8arrays/from-string')

// setup a repo
const repo = new IPFSRepo('example')

// create a block
const data = uint8ArrayFromString('hello world')
const multihash = await multihashing(data, 'sha2-256')

const cid = new CID(multihash)
const block = new Block(data, cid)

// create a service
const service = new BlockService(repo)

// add the block, then retrieve it
await service.put(block)

const result = await service.get(cid)
console.log(uint8ArrayEquals(block.data, result.data))
// => true

Browser: Browserify, Webpack, other bundlers

var BlockService = require('ipfs-block-service')

Browser: <script> Tag

Loading this module through a script tag will make the IpfsBlockService obj available in the global namespace.

<script src="https://unpkg.com/ipfs-block-service/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/ipfs-block-service/dist/index.js"></script>

API

See https://ipfs.github.io/js-ipfs-block-service

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT

changelog

0.19.1 (2021-08-11)

0.19.0 (2021-03-05)

Features

0.18.0 (2020-08-05)

Bug Fixes

  • replace node buffers with uint8arrays (#105) (804c5cf)

BREAKING CHANGES

    • All uses of Buffers have been replaced with Uint8Arrays
  • The ipfs-repo this module uses only returns Uint8Arrays

0.17.1 (2020-05-05)

Features

0.17.0 (2020-04-16)

Bug Fixes

  • throw if asked to delete a block we don't have (#88) (4ffb28c)

Features

  • support passing AbortSignals to the configured repo (#89) (0c5f17c)

BREAKING CHANGES

  • bs.delete(cid) used to ignore mystery CIDs, now it throws.

0.16.0 (2019-06-18)

Chores

  • callbacks -> async / await (9fb54d2)

BREAKING CHANGES

  • All places in the API that used callbacks are now replaced with async/await

0.15.2 (2018-11-08)

0.15.1 (2018-10-27)

Features

0.15.0 (2018-10-26)

0.14.0 (2018-04-10)

0.13.0 (2017-11-06)

Bug Fixes

0.12.0 (2017-07-23)

Features

0.10.0 (2017-07-04)

Features

0.9.1 (2017-05-23)

0.9.0 (2017-03-21)

Features

  • refactor for new ipfs-repo interface (7eff97f)

0.8.3 (2017-02-09)

0.8.2 (2017-02-09)

0.8.1 (2017-01-29)

0.8.0 (2016-12-23)

Features

  • pass CID directly into bitswap (f0c3e42)

0.7.2 (2016-12-13)

0.7.1 (2016-12-09)

0.7.0 (2016-11-03)

0.6.0 (2016-10-26)

Bug Fixes

Features

  • bitswap support back again (e92a118)
  • CID support on put and putStream (9e99029)
  • cids on get and delete (58b7c98)
  • remove extension support, support new ipfs-block and ipfs-repo (bf2287a)

0.5.0 (2016-09-08)

Bug Fixes

  • use bs.getBlocks and cleanup interface (3e5b314)

0.4.0 (2016-05-07)

Features

  • add goOffline method (e15b828)
  • Add integration with bitswap (00be067)

0.3.0 (2016-05-02)

0.2.8 (2016-04-30)

0.2.7 (2016-04-30)

0.2.6 (2016-04-30)

0.2.5 (2016-04-28)

0.2.4 (2016-04-27)

0.2.3 (2016-04-24)

Bug Fixes

  • block-service: limit all async calls (f256451)

0.2.2 (2016-04-24)

Bug Fixes

  • block-service: use correct cb interface for writes (bec44b3), closes #13

0.2.1 (2016-04-24)

Bug Fixes

  • block-service: return errors for addBlock (0fea48d)

0.2.0 (2016-04-19)

Bug Fixes

  • Latest dep and linting (7c9b917)
  • Specify types instead of extensions (addf54b)

0.1.0 (2016-01-29)