Socket
Socket
Sign inDemoInstall

ipfs-block-service

Package Overview
Dependencies
1
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-block-service


Version published
Weekly downloads
826
increased by11.17%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

0.4.0 (2016-05-07)

Features

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

<a name="0.3.0"></a>

Readme

Source

IPFS Block Service JavaScript Implementation

Travis CI Circle CI Coverage Status Dependency Status js-standard-style

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

Description

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][repo] as its datastore for blocks, and uses Bitswap to fetch blocks from the network.

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

Example

const BlockService = require('ipfs-block-service')
const Block = require('ipfs-block')
const IPFSRepo = require('ipfs-repo')  // storage repo
const memstore = require('abstract-blob-store')  // in-memory store

// setup a repo
var repo = new IPFSRepo('example', { stores: memstore })

// create a block
const block = new Block('hello warld')
console.log(block.data)
console.log(block.key)

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

// add the block, then retrieve it
bs.addBlock(block, function (err) {
  bs.getBlock(block.key, function (err, b) {
    console.log(block.data.toString() === b.data.toString())
  })
})

outputs

<Buffer 68 65 6c 6c 6f 20 77 61 72 6c 64>

<Buffer 12 20 db 3c 15 23 3f f3 84 8f 42 fe 3b 74 78 90 90 5a 80 7e a6 ef 2b 6d 2f 3c 8b 2c b7 ae be 86 3c 4d>

true

Installation

npm

> npm i ipfs-block-service

Setup

Node.js

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

Browser: Browserify, Webpack, other bundlers

The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process.

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://npmcdn.com/ipfs-block-service/dist/index.min.js"></script>
<!-- OR -->
<script src="https://npmcdn.com/ipfs-block-service/dist/index.js"></script>

You can find the API documentation here

License

MIT

Keywords

FAQs

Last updated on 07 May 2016

Did you know?

Socket

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