Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: reduce bundle size 2
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Dec 24, 2018
1 parent 2525b1b commit b9809a6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/runtime/ipld-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'
const mergeOptions = require('merge-options')

module.exports = (blockService, options = {}) => {
return mergeOptions({
blockService: blockService
}, options)
}
47 changes: 47 additions & 0 deletions src/core/runtime/ipld-nodejs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict'
const mergeOptions = require('merge-options')

// All known (non-default) IPLD formats
const IpldFormats = {
get 'bitcoin-block' () {
return require('ipld-bitcoin')
},
get 'eth-account-snapshot' () {
return require('ipld-ethereum').ethAccountSnapshot
},
get 'eth-block' () {
return require('ipld-ethereum').ethBlock
},
get 'eth-block-list' () {
return require('ipld-ethereum').ethBlockList
},
get 'eth-state-trie' () {
return require('ipld-ethereum').ethStateTrie
},
get 'eth-storage-trie' () {
return require('ipld-ethereum').ethStorageTrie
},
get 'eth-tx' () {
return require('ipld-ethereum').ethTx
},
get 'eth-tx-trie' () {
return require('ipld-ethereum').ethTxTrie
},
get 'git-raw' () {
return require('ipld-git')
},
get 'zcash-block' () {
return require('ipld-zcash')
}
}

module.exports = (blockService, options = {}) => {
return mergeOptions({
blockService: blockService,
loadFormat: (codec, callback) => {
this.log('Loading IPLD format', codec)
if (IpldFormats[codec]) return callback(null, IpldFormats[codec])
callback(new Error(`Missing IPLD format "${codec}"`))
}
}, options)
}

0 comments on commit b9809a6

Please sign in to comment.