chore: update to new multiformats (#948)

BREAKING CHANGE: uses the CID class from the new multiformats module

Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
This commit is contained in:
Alex Potsides
2021-07-09 07:43:34 +01:00
committed by GitHub
parent 39b03586e8
commit 13cf476148
19 changed files with 81 additions and 78 deletions

View File

@ -17,11 +17,11 @@
"dependencies": {
"@babel/preset-env": "^7.13.0",
"libp2p": "../../",
"libp2p-bootstrap": "^0.12.1",
"libp2p-mplex": "^0.10.0",
"libp2p-noise": "^2.0.0",
"libp2p-webrtc-star": "^0.22.0",
"libp2p-websockets": "^0.15.0"
"libp2p-bootstrap": "^0.13.0",
"libp2p-mplex": "^0.10.4",
"libp2p-noise": "^4.0.0",
"libp2p-webrtc-star": "^0.23.0",
"libp2p-websockets": "^0.16.1"
},
"devDependencies": {
"@babel/cli": "^7.13.10",

View File

@ -5,7 +5,7 @@ const Libp2p = require('../../')
const TCP = require('libp2p-tcp')
const Mplex = require('libp2p-mplex')
const { NOISE } = require('libp2p-noise')
const CID = require('cids')
const { CID } = require('multiformats/cid')
const KadDHT = require('libp2p-kad-dht')
const all = require('it-all')
@ -51,10 +51,10 @@ const createNode = async () => {
// Wait for onConnect handlers in the DHT
await delay(100)
const cid = new CID('QmTp9VkYvnHyrqKQuFPiuZkiX9gPcqj6x5LJ1rmWuSySnL')
const cid = CID.parse('QmTp9VkYvnHyrqKQuFPiuZkiX9gPcqj6x5LJ1rmWuSySnL')
await node1.contentRouting.provide(cid)
console.log('Node %s is providing %s', node1.peerId.toB58String(), cid.toBaseEncodedString())
console.log('Node %s is providing %s', node1.peerId.toB58String(), cid.toString())
// wait for propagation
await delay(300)

View File

@ -81,7 +81,7 @@ Instead of calling `peerRouting.findPeer`, we will use `contentRouting.provide`
```JavaScript
await node1.contentRouting.provide(cid)
console.log('Node %s is providing %s', node1.peerId.toB58String(), cid.toBaseEncodedString())
console.log('Node %s is providing %s', node1.peerId.toB58String(), cid.toString())
const provs = await all(node3.contentRouting.findProviders(cid, { timeout: 5000 }))

View File

@ -21,11 +21,11 @@
},
"dependencies": {
"libp2p": "../../",
"libp2p-bootstrap": "^0.12.1",
"libp2p-mplex": "^0.10.1",
"libp2p-noise": "^2.0.1",
"libp2p-webrtc-direct": "^0.6.0",
"peer-id": "^0.14.3"
"libp2p-bootstrap": "^0.13.0",
"libp2p-mplex": "^0.10.4",
"libp2p-noise": "^4.0.0",
"libp2p-webrtc-direct": "^0.7.0",
"peer-id": "^0.15.0"
},
"browser": {
"ipfs": "ipfs/dist/index.min.js"