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

Commit

Permalink
refactor: switch to bignumber.js (#1803)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: All API methods that returned [`big.js`](https://github.com/MikeMcl/big.js/) instances now return [`bignumber.js`](https://github.com/MikeMcl/bignumber.js/) instances.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
  • Loading branch information
alanshaw committed Jan 15, 2019
1 parent 8ca6471 commit 6de6adf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
26 changes: 13 additions & 13 deletions package.json
Expand Up @@ -62,7 +62,7 @@
},
"homepage": "https://github.com/ipfs/js-ipfs#readme",
"devDependencies": {
"aegir": "^17.0.1",
"aegir": "^17.1.1",
"chai": "^4.2.0",
"delay": "^4.1.0",
"detect-node": "^2.0.4",
Expand All @@ -71,7 +71,7 @@
"execa": "^1.0.0",
"form-data": "^2.3.3",
"hat": "0.0.3",
"interface-ipfs-core": "~0.92.0",
"interface-ipfs-core": "~0.96.0",
"ipfsd-ctl": "~0.40.1",
"ncp": "^2.0.0",
"qs": "^6.5.2",
Expand All @@ -82,7 +82,7 @@
"dependencies": {
"@nodeutils/defaults-deep": "^1.1.0",
"async": "^2.6.1",
"big.js": "^5.2.2",
"bignumber.js": "^8.0.2",
"binary-querystring": "~0.1.2",
"bl": "^2.1.2",
"boom": "^7.2.0",
Expand All @@ -105,14 +105,14 @@
"hoek": "^6.1.2",
"human-to-milliseconds": "^1.0.0",
"interface-datastore": "~0.6.0",
"ipfs-bitswap": "~0.21.0",
"ipfs-bitswap": "~0.22.0",
"ipfs-block": "~0.8.0",
"ipfs-block-service": "~0.15.1",
"ipfs-http-client": "^28.1.0",
"ipfs-http-client": "^29.0.0",
"ipfs-http-response": "~0.2.1",
"ipfs-mfs": "~0.8.0",
"ipfs-multipart": "~0.1.0",
"ipfs-repo": "~0.26.0",
"ipfs-repo": "~0.26.1",
"ipfs-unixfs": "~0.1.16",
"ipfs-unixfs-engine": "~0.35.3",
"ipld": "~0.20.1",
Expand All @@ -121,22 +121,22 @@
"ipld-ethereum": "^2.0.1",
"ipld-git": "~0.2.2",
"ipld-zcash": "~0.1.6",
"ipns": "~0.4.3",
"ipns": "~0.5.0",
"is-ipfs": "~0.4.8",
"is-pull-stream": "~0.0.0",
"is-stream": "^1.1.0",
"joi": "^14.3.0",
"joi-browser": "^13.4.0",
"joi-multiaddr": "^3.0.0",
"joi-multiaddr": "^4.0.0",
"libp2p": "~0.24.1",
"libp2p-bootstrap": "~0.9.3",
"libp2p-crypto": "~0.14.1",
"libp2p-kad-dht": "~0.12.1",
"libp2p-crypto": "~0.16.0",
"libp2p-kad-dht": "~0.14.4",
"libp2p-keychain": "~0.3.3",
"libp2p-mdns": "~0.12.0",
"libp2p-mplex": "~0.8.4",
"libp2p-record": "~0.6.1",
"libp2p-secio": "~0.10.1",
"libp2p-secio": "~0.11.0",
"libp2p-tcp": "~0.13.0",
"libp2p-webrtc-star": "~0.15.5",
"libp2p-websocket-star": "~0.10.0",
Expand Down Expand Up @@ -169,11 +169,11 @@
"pull-stream-to-stream": "^1.3.4",
"pump": "^3.0.0",
"read-pkg-up": "^4.0.0",
"readable-stream": "3.0.6",
"readable-stream": "^3.1.1",
"receptacle": "^1.3.2",
"stream-to-pull-stream": "^1.7.2",
"tar-stream": "^1.6.2",
"temp": "~0.8.3",
"temp": "~0.9.0",
"update-notifier": "^2.5.0",
"varint": "^5.0.0",
"yargs": "^12.0.5",
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/bitswap.js
Expand Up @@ -3,7 +3,7 @@
const OFFLINE_ERROR = require('../utils').OFFLINE_ERROR
const promisify = require('promisify-es6')
const setImmediate = require('async/setImmediate')
const Big = require('big.js')
const Big = require('bignumber.js')
const CID = require('cids')
const PeerId = require('peer-id')
const errCode = require('err-code')
Expand Down
20 changes: 14 additions & 6 deletions src/core/components/libp2p.js
Expand Up @@ -87,15 +87,23 @@ module.exports = function libp2p (self) {
peerBook: self._peerInfoBook
})

let discoveredPeers = []

const putAndDial = peerInfo => {
self._peerInfoBook.put(peerInfo)
self._libp2pNode.dial(peerInfo, () => {})
}

self._libp2pNode.on('start', () => {
discoveredPeers.forEach(putAndDial)
discoveredPeers = []
})

self._libp2pNode.on('peer:discovery', (peerInfo) => {
const dial = () => {
self._peerInfoBook.put(peerInfo)
self._libp2pNode.dial(peerInfo, () => {})
}
if (self.isOnline()) {
dial()
putAndDial(peerInfo)
} else {
self._libp2pNode.once('start', dial)
discoveredPeers.push(peerInfo)
}
})

Expand Down
2 changes: 1 addition & 1 deletion src/core/components/stats.js
@@ -1,7 +1,7 @@
'use strict'

const promisify = require('promisify-es6')
const Big = require('big.js')
const Big = require('bignumber.js')
const Pushable = require('pull-pushable')
const human = require('human-to-milliseconds')
const toStream = require('pull-stream-to-stream')
Expand Down

0 comments on commit 6de6adf

Please sign in to comment.