🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

ipfs-block-service

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-block-service - npm Package Compare versions

Comparing version
0.9.1
to
0.10.0
+10
-10
dist/index.js

@@ -104,3 +104,3 @@ var IpfsBlockService =

*/
goOnline (bitswap) {
setExchange (bitswap) {
this._bitswap = bitswap

@@ -114,3 +114,3 @@ }

*/
goOffline () {
unsetExchange () {
this._bitswap = null

@@ -124,3 +124,3 @@ }

*/
isOnline () {
hasExchange () {
return this._bitswap != null

@@ -137,7 +137,7 @@ }

put (block, callback) {
if (this.isOnline()) {
if (this.hasExchange()) {
return this._bitswap.put(block, callback)
}
this._repo.blockstore.put(block, callback)
this._repo.blocks.put(block, callback)
}

@@ -153,7 +153,7 @@

putMany (blocks, callback) {
if (this.isOnline()) {
if (this.hasExchange()) {
return this._bitswap.putMany(blocks, callback)
}
this._repo.blockstore.putMany(blocks, callback)
this._repo.blocks.putMany(blocks, callback)
}

@@ -169,7 +169,7 @@

get (cid, callback) {
if (this.isOnline()) {
if (this.hasExchange()) {
return this._bitswap.get(cid, callback)
}
return this._repo.blockstore.get(cid, callback)
return this._repo.blocks.get(cid, callback)
}

@@ -185,3 +185,3 @@

delete (cid, callback) {
this._repo.blockstore.delete(cid, callback)
this._repo.blocks.delete(cid, callback)
}

@@ -188,0 +188,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"sources":["webpack:///webpack/bootstrap 2ec7f80bd509952e6dd4","webpack:///./src/index.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;AChEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,gBAAgB;AAC7B,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,gBAAgB;AAC7B,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,IAAI;AACjB,aAAa,uBAAuB;AACpC,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,IAAI;AACjB,aAAa,gBAAgB;AAC7B,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 2ec7f80bd509952e6dd4","'use strict'\n\n/**\n * BlockService is a hybrid block datastore. It stores data in a local\n * datastore and may retrieve data from a remote Exchange.\n * It uses an internal `datastore.Datastore` instance to store values.\n */\nclass BlockService {\n /**\n * Create a new BlockService\n *\n * @param {IPFSRepo} ipfsRepo\n * @returns {BlockService}\n */\n constructor (ipfsRepo) {\n this._repo = ipfsRepo\n this._bitswap = null\n }\n\n /**\n * Add a bitswap instance that communicates with the\n * network to retreive blocks that are not in the local store.\n *\n * If the node is online all requests for blocks first\n * check locally and afterwards ask the network for the blocks.\n *\n * @param {Bitswap} bitswap\n * @returns {void}\n */\n goOnline (bitswap) {\n this._bitswap = bitswap\n }\n\n /**\n * Go offline, i.e. drop the reference to bitswap.\n *\n * @returns {void}\n */\n goOffline () {\n this._bitswap = null\n }\n\n /**\n * Is the blockservice online, i.e. is bitswap present.\n *\n * @returns {bool}\n */\n isOnline () {\n return this._bitswap != null\n }\n\n /**\n * Put a block to the underlying datastore.\n *\n * @param {Block} block\n * @param {function(Error)} callback\n * @returns {void}\n */\n put (block, callback) {\n if (this.isOnline()) {\n return this._bitswap.put(block, callback)\n }\n\n this._repo.blockstore.put(block, callback)\n }\n\n /**\n * Put a multiple blocks to the underlying datastore.\n *\n * @param {Array<Block>} blocks\n * @param {function(Error)} callback\n * @returns {void}\n */\n putMany (blocks, callback) {\n if (this.isOnline()) {\n return this._bitswap.putMany(blocks, callback)\n }\n\n this._repo.blockstore.putMany(blocks, callback)\n }\n\n /**\n * Get a block by cid.\n *\n * @param {CID} cid\n * @param {function(Error, Block)} callback\n * @returns {void}\n */\n get (cid, callback) {\n if (this.isOnline()) {\n return this._bitswap.get(cid, callback)\n }\n\n return this._repo.blockstore.get(cid, callback)\n }\n\n /**\n * Delete a block from the blockstore.\n *\n * @param {CID} cid\n * @param {function(Error)} callback\n * @return {void}\n */\n delete (cid, callback) {\n this._repo.blockstore.delete(cid, callback)\n }\n}\n\nmodule.exports = BlockService\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/index.js\n// module id = 0\n// module chunks = 0"],"sourceRoot":""}
{"version":3,"sources":["webpack:///webpack/bootstrap 3b921ddddcf4db39dde9","webpack:///./src/index.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;AChEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,gBAAgB;AAC7B,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,gBAAgB;AAC7B,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,IAAI;AACjB,aAAa,uBAAuB;AACpC,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,IAAI;AACjB,aAAa,gBAAgB;AAC7B,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 3b921ddddcf4db39dde9","'use strict'\n\n/**\n * BlockService is a hybrid block datastore. It stores data in a local\n * datastore and may retrieve data from a remote Exchange.\n * It uses an internal `datastore.Datastore` instance to store values.\n */\nclass BlockService {\n /**\n * Create a new BlockService\n *\n * @param {IPFSRepo} ipfsRepo\n * @returns {BlockService}\n */\n constructor (ipfsRepo) {\n this._repo = ipfsRepo\n this._bitswap = null\n }\n\n /**\n * Add a bitswap instance that communicates with the\n * network to retreive blocks that are not in the local store.\n *\n * If the node is online all requests for blocks first\n * check locally and afterwards ask the network for the blocks.\n *\n * @param {Bitswap} bitswap\n * @returns {void}\n */\n setExchange (bitswap) {\n this._bitswap = bitswap\n }\n\n /**\n * Go offline, i.e. drop the reference to bitswap.\n *\n * @returns {void}\n */\n unsetExchange () {\n this._bitswap = null\n }\n\n /**\n * Is the blockservice online, i.e. is bitswap present.\n *\n * @returns {bool}\n */\n hasExchange () {\n return this._bitswap != null\n }\n\n /**\n * Put a block to the underlying datastore.\n *\n * @param {Block} block\n * @param {function(Error)} callback\n * @returns {void}\n */\n put (block, callback) {\n if (this.hasExchange()) {\n return this._bitswap.put(block, callback)\n }\n\n this._repo.blocks.put(block, callback)\n }\n\n /**\n * Put a multiple blocks to the underlying datastore.\n *\n * @param {Array<Block>} blocks\n * @param {function(Error)} callback\n * @returns {void}\n */\n putMany (blocks, callback) {\n if (this.hasExchange()) {\n return this._bitswap.putMany(blocks, callback)\n }\n\n this._repo.blocks.putMany(blocks, callback)\n }\n\n /**\n * Get a block by cid.\n *\n * @param {CID} cid\n * @param {function(Error, Block)} callback\n * @returns {void}\n */\n get (cid, callback) {\n if (this.hasExchange()) {\n return this._bitswap.get(cid, callback)\n }\n\n return this._repo.blocks.get(cid, callback)\n }\n\n /**\n * Delete a block from the blockstore.\n *\n * @param {CID} cid\n * @param {function(Error)} callback\n * @return {void}\n */\n delete (cid, callback) {\n this._repo.blocks.delete(cid, callback)\n }\n}\n\nmodule.exports = BlockService\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/index.js\n// module id = 0\n// module chunks = 0"],"sourceRoot":""}

@@ -1,1 +0,1 @@

var IpfsBlockService=function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=1)}([function(module,exports,__webpack_require__){"use strict";class BlockService{constructor(ipfsRepo){this._repo=ipfsRepo,this._bitswap=null}goOnline(bitswap){this._bitswap=bitswap}goOffline(){this._bitswap=null}isOnline(){return null!=this._bitswap}put(block,callback){if(this.isOnline())return this._bitswap.put(block,callback);this._repo.blockstore.put(block,callback)}putMany(blocks,callback){if(this.isOnline())return this._bitswap.putMany(blocks,callback);this._repo.blockstore.putMany(blocks,callback)}get(cid,callback){return this.isOnline()?this._bitswap.get(cid,callback):this._repo.blockstore.get(cid,callback)}delete(cid,callback){this._repo.blockstore.delete(cid,callback)}}module.exports=BlockService},function(module,exports,__webpack_require__){module.exports=__webpack_require__(0)}]);
var IpfsBlockService=function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=1)}([function(module,exports,__webpack_require__){"use strict";class BlockService{constructor(ipfsRepo){this._repo=ipfsRepo,this._bitswap=null}setExchange(bitswap){this._bitswap=bitswap}unsetExchange(){this._bitswap=null}hasExchange(){return null!=this._bitswap}put(block,callback){if(this.hasExchange())return this._bitswap.put(block,callback);this._repo.blocks.put(block,callback)}putMany(blocks,callback){if(this.hasExchange())return this._bitswap.putMany(blocks,callback);this._repo.blocks.putMany(blocks,callback)}get(cid,callback){return this.hasExchange()?this._bitswap.get(cid,callback):this._repo.blocks.get(cid,callback)}delete(cid,callback){this._repo.blocks.delete(cid,callback)}}module.exports=BlockService},function(module,exports,__webpack_require__){module.exports=__webpack_require__(0)}]);
{
"name": "ipfs-block-service",
"version": "0.9.1",
"version": "0.10.0",
"description": "JavaScript Implementation of BlockService",

@@ -41,8 +41,8 @@ "main": "src/index.js",

"aegir": "^11.0.2",
"async": "^2.4.1",
"chai": "^3.5.0",
"async": "^2.5.0",
"chai": "^4.0.2",
"cids": "^0.5.0",
"dirty-chai": "^1.2.2",
"dirty-chai": "^2.0.0",
"ipfs-block": "~0.6.0",
"ipfs-repo": "~0.13.1",
"ipfs-repo": "~0.15.0",
"lodash": "^4.17.4",

@@ -63,2 +63,3 @@ "multihashing-async": "^0.4.5",

"Greenkeeper <support@greenkeeper.io>",
"Pedro Teixeira <i@pgte.me>",
"Richard Littauer <richard.littauer@gmail.com>",

@@ -65,0 +66,0 @@ "Stephen Whitmore <stephen.whitmore@gmail.com>",

@@ -30,3 +30,3 @@ 'use strict'

*/
goOnline (bitswap) {
setExchange (bitswap) {
this._bitswap = bitswap

@@ -40,3 +40,3 @@ }

*/
goOffline () {
unsetExchange () {
this._bitswap = null

@@ -50,3 +50,3 @@ }

*/
isOnline () {
hasExchange () {
return this._bitswap != null

@@ -63,7 +63,7 @@ }

put (block, callback) {
if (this.isOnline()) {
if (this.hasExchange()) {
return this._bitswap.put(block, callback)
}
this._repo.blockstore.put(block, callback)
this._repo.blocks.put(block, callback)
}

@@ -79,7 +79,7 @@

putMany (blocks, callback) {
if (this.isOnline()) {
if (this.hasExchange()) {
return this._bitswap.putMany(blocks, callback)
}
this._repo.blockstore.putMany(blocks, callback)
this._repo.blocks.putMany(blocks, callback)
}

@@ -95,7 +95,7 @@

get (cid, callback) {
if (this.isOnline()) {
if (this.hasExchange()) {
return this._bitswap.get(cid, callback)
}
return this._repo.blockstore.get(cid, callback)
return this._repo.blocks.get(cid, callback)
}

@@ -111,3 +111,3 @@

delete (cid, callback) {
this._repo.blockstore.delete(cid, callback)
this._repo.blocks.delete(cid, callback)
}

@@ -114,0 +114,0 @@ }