diff --git a/examples/delegated-routing/README.md b/examples/delegated-routing/README.md index 8111e1e9..362d0556 100644 --- a/examples/delegated-routing/README.md +++ b/examples/delegated-routing/README.md @@ -36,7 +36,7 @@ This should open your browser to http://localhost:3000. If it does not, go ahead ### Finding Content via the Delegate 1. Add a file to your IPFS node. From this example root you can do `ipfs add ./README.md` to add the example readme. -2. Copy the hash from line 5, it will look something like *Qmf33vz4HJFkqgH7XPP1uA6atYKTX1BWQEQthzpKcAdeyZ*. +2. Copy the hash from line 5, it will look something like *QmV8QZ1m4fi57fbmaYDAkaTSTjHZVLUJmsqvaP6EcUyUNb*. 3. In the browser, paste the hash into the *Hash* field and hit `Find`. The readme contents should display. This will do a few things: diff --git a/examples/delegated-routing/package.json b/examples/delegated-routing/package.json index e4b53508..377e5a59 100644 --- a/examples/delegated-routing/package.json +++ b/examples/delegated-routing/package.json @@ -12,6 +12,7 @@ "libp2p-secio": "~0.12.5", "libp2p-webrtc-star": "~0.18.6", "libp2p-websockets": "~0.13.6", + "peer-id": "^0.13.13", "react": "^16.8.6", "react-dom": "^16.8.6", "react-scripts": "^3.2.0" diff --git a/examples/delegated-routing/src/App.js b/examples/delegated-routing/src/App.js index 40095987..c19c7630 100644 --- a/examples/delegated-routing/src/App.js +++ b/examples/delegated-routing/src/App.js @@ -4,6 +4,7 @@ import React from 'react' import Ipfs from 'ipfs' import libp2pConfig from './libp2p-configuration' +import PeerId from 'peer-id' const BootstrapNode = '/ip4/127.0.0.1/tcp/4010/ws/p2p/QmZrsjJ7v9QoJNjDJmjsQ8947wiK3UnaPPLQvrTSRDAZ2d' @@ -43,10 +44,13 @@ class App extends React.Component { isLoading: this.state.isLoading + 1 }) - const data = await this.ipfs.cat(this.state.hash) + const chunks = [] + for await (const chunk of this.ipfs.cat(this.state.hash)) { + chunks.push(chunk) + } this.setState({ - response: data.toString(), + response: Buffer.concat(chunks).toString(), isLoading: this.state.isLoading - 1 }) } @@ -56,7 +60,8 @@ class App extends React.Component { isLoading: this.state.isLoading + 1 }) - const results = await this.ipfs.dht.findpeer(this.state.peer) + const peerId = PeerId.createFromB58String(this.state.peer) + const results = await this.ipfs.libp2p.peerRouting.findPeer(peerId) this.setState({ response: JSON.stringify(results, null, 2),