Socket
Socket
Sign inDemoInstall

ipfs-block-service

Package Overview
Dependencies
0
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ipfs-block-service

JavaScript Implementation of BlockService


Version published
Weekly downloads
720
decreased by-44.62%
Maintainers
2
Created
Weekly downloads
 

Changelog

Source

0.15.0 (2018-10-26)

<a name="0.14.0"></a>

Readme

Source

IPFS Block Service

standard-readme compliant Circle CI Coverage Status 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('ipfs-block')
const multihashing = require('multihashing-async')
const IPFSRepo = require('ipfs-repo')  // storage repo

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

// create a block
const data = new Buffer('hello world')
multihashing(data, 'sha2-256', (err, multihash) => {
  if (err) {
    throw err
  }

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

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

  // add the block, then retrieve it
  bs.put(block, (err) => {
    if (err) {
      throw err
    }
    bs.get(cid, (err, b) => {
      if (err) {
        throw err
      }
      console.log(block.data.toString() === b.data.toString())
      // => 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

Keywords

FAQs

Last updated on 26 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc