mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-13 09:11:20 +00:00
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:
@ -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)
|
||||
|
@ -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 }))
|
||||
|
||||
|
Reference in New Issue
Block a user