mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-28 18:01:19 +00:00
chore: update deps
This commit is contained in:
parent
f596ecdaa5
commit
1eaf7619a7
3
examples/delegated-routing/.env
Normal file
3
examples/delegated-routing/.env
Normal file
@ -0,0 +1,3 @@
|
||||
# required because react-scripts scans *up* the tree from this project and finds
|
||||
# a conflicting version of eslint in the node_modules dir for js-ipfs.
|
||||
SKIP_PREFLIGHT_CHECK=true
|
@ -1,7 +1,3 @@
|
||||
❗❗Outdated: This example is still not refactored with the `0.27.*` release.
|
||||
WIP on [libp2p/js-libp2p#507](https://github.com/libp2p/js-libp2p/pull/507)
|
||||
======
|
||||
|
||||
# Delegated Routing with Libp2p and IPFS
|
||||
|
||||
This example shows how to use delegated peer and content routing. The [Peer and Content Routing Example](../peer-and-content-routing) focuses
|
||||
@ -21,7 +17,7 @@ various Peer Discovery modules and see the impact it has on your Peer count.
|
||||
|
||||
1. Install IPFS locally if you dont already have it. [Install Guide](https://docs.ipfs.io/introduction/install/)
|
||||
2. Run the IPFS daemon: `ipfs daemon`
|
||||
3. The daemon will output a line about its API address, like `API server listening on /ip4/127.0.0.1/tcp/8080`
|
||||
3. The daemon will output a line about its API address, like `API server listening on /ip4/127.0.0.1/tcp/5001`
|
||||
4. In another window output the addresses of the node: `ipfs id`. Make note of the websocket address, it will contain `/ws/` in the address.
|
||||
- If there is no websocket address, you will need to add it in the ipfs config file (`~/.ipfs/config`)
|
||||
- Add to Swarm Addresses something like: `"/ip4/127.0.0.1/tcp/4010/ws"`
|
||||
|
@ -3,18 +3,18 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"ipfs": "~0.40.0",
|
||||
"ipfs": "~0.47.0",
|
||||
"libp2p": "../..",
|
||||
"libp2p-delegated-content-routing": "~0.4.1",
|
||||
"libp2p-delegated-peer-routing": "~0.4.0",
|
||||
"libp2p-kad-dht": "~0.18.2",
|
||||
"libp2p-mplex": "~0.9.3",
|
||||
"libp2p-secio": "~0.12.1",
|
||||
"libp2p-webrtc-star": "~0.17.0",
|
||||
"libp2p-websockets": "~0.13.1",
|
||||
"react": "^16.12.0",
|
||||
"react-dom": "^16.12.0",
|
||||
"react-scripts": "3.3.0"
|
||||
"libp2p-delegated-content-routing": "~0.5.0",
|
||||
"libp2p-delegated-peer-routing": "~0.5.0",
|
||||
"libp2p-kad-dht": "~0.19.7",
|
||||
"libp2p-mplex": "~0.9.5",
|
||||
"libp2p-secio": "~0.12.5",
|
||||
"libp2p-webrtc-star": "~0.18.6",
|
||||
"libp2p-websockets": "~0.13.6",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6",
|
||||
"react-scripts": "^3.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start"
|
||||
|
@ -5,7 +5,7 @@ import React from 'react'
|
||||
import Ipfs from 'ipfs'
|
||||
import libp2pConfig from './libp2p-configuration'
|
||||
|
||||
const BootstrapNode = '/ip4/127.0.0.1/tcp/4004/ws/ipfs/QmPHafDaco9vynQ93MHv5cRSW6UCECycCGdTRafL8X5WEj'
|
||||
const BootstrapNode = '/ip4/127.0.0.1/tcp/4010/ws/p2p/QmZrsjJ7v9QoJNjDJmjsQ8947wiK3UnaPPLQvrTSRDAZ2d'
|
||||
|
||||
class App extends React.Component {
|
||||
constructor (props) {
|
||||
@ -64,8 +64,8 @@ class App extends React.Component {
|
||||
})
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
window.ipfs = this.ipfs = new Ipfs({
|
||||
async componentDidMount () {
|
||||
window.ipfs = this.ipfs = await Ipfs.create({
|
||||
config: {
|
||||
Addresses: {
|
||||
Swarm: []
|
||||
@ -88,21 +88,14 @@ class App extends React.Component {
|
||||
libp2p: libp2pConfig
|
||||
})
|
||||
|
||||
this.ipfs.on('ready', async () => {
|
||||
if (this.peerInterval) {
|
||||
clearInterval(this.peerInterval)
|
||||
}
|
||||
await this.ipfs.swarm.connect(BootstrapNode)
|
||||
console.log('Connected!')
|
||||
|
||||
this.peerInterval = setInterval(async () => {
|
||||
const peers = await this.ipfs.swarm.peers()
|
||||
|
||||
await this.ipfs.swarm.connect(BootstrapNode)
|
||||
console.log('Connected!')
|
||||
|
||||
this.peerInterval = setInterval(async () => {
|
||||
const peers = await this.ipfs.swarm.peers()
|
||||
|
||||
if (peers) this.setState({peers: peers.length})
|
||||
}, 2500)
|
||||
})
|
||||
if (peers) this.setState({ peers: peers.length })
|
||||
}, 2500)
|
||||
}
|
||||
|
||||
render () {
|
||||
|
@ -10,8 +10,7 @@ const KadDHT = require('libp2p-kad-dht')
|
||||
const DelegatedPeerRouter = require('libp2p-delegated-peer-routing')
|
||||
const DelegatedContentRouter = require('libp2p-delegated-content-routing')
|
||||
|
||||
export default function Libp2pConfiguration ({peerInfo}) {
|
||||
const wrtcstar = new WebRTCStar({id: peerInfo.id})
|
||||
export default function Libp2pConfiguration ({peerId}) {
|
||||
const delegatedApiOptions = {
|
||||
host: '127.0.0.1',
|
||||
protocol: 'http',
|
||||
@ -19,7 +18,7 @@ export default function Libp2pConfiguration ({peerInfo}) {
|
||||
}
|
||||
|
||||
return new Libp2p({
|
||||
peerInfo,
|
||||
peerId,
|
||||
// Lets limit the connection managers peers and have it check peer health less frequently
|
||||
connectionManager: {
|
||||
maxPeers: 10,
|
||||
@ -27,16 +26,13 @@ export default function Libp2pConfiguration ({peerInfo}) {
|
||||
},
|
||||
modules: {
|
||||
contentRouting: [
|
||||
new DelegatedContentRouter(peerInfo.id, delegatedApiOptions)
|
||||
new DelegatedContentRouter(peerId, delegatedApiOptions)
|
||||
],
|
||||
peerRouting: [
|
||||
new DelegatedPeerRouter(delegatedApiOptions)
|
||||
],
|
||||
peerDiscovery: [
|
||||
wrtcstar.discovery
|
||||
],
|
||||
transport: [
|
||||
wrtcstar,
|
||||
WebRTCStar,
|
||||
Websockets
|
||||
],
|
||||
streamMuxer: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user