mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 10:32:14 +00:00
fix: use new apis
This commit is contained in:
parent
1eaf7619a7
commit
a319b5e2e5
@ -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:
|
||||
|
@ -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"
|
||||
|
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user