Skip to content

Commit

Permalink
docs: fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobheun committed Nov 8, 2018
1 parent e92053d commit ebcd3f6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ This example creates a simple chat app in your terminal.
1. Run the listener in window 1, `node listener.js`
2. Run the dialer in window 2, `node dialer.js`
3. Type a message in either window and hit _enter_
4. Tell youself secrets to your hearts content!
4. Tell yourself secrets to your hearts content!
2 changes: 1 addition & 1 deletion examples/chat/src/libp2p-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const TCP = require('libp2p-tcp')
const MulticastDNS = require('libp2p-mdns')
const WS = require('libp2p-websockets')
const Bootstrap = require('libp2p-railing')
const Bootstrap = require('libp2p-bootstrap')
const spdy = require('libp2p-spdy')
const KadDHT = require('libp2p-kad-dht')
const mplex = require('libp2p-mplex')
Expand Down
4 changes: 2 additions & 2 deletions examples/delegated-routing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ 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`
4. In another window output the addresses of the node: `ipfs id`. Make note of the websocket address, is will contain `/ws/` in the address.
5. In `./src/libp2p-bundle.js` replace the `delegatedApiOptions` host and port of your node if they are different.
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.
5. In `./src/libp2p-bundle.js` replace the `delegatedApiOptions` host and port of your node, if they are different.
6. In `./src/App.js` replace `BootstrapNode` with your nodes Websocket address from step 4.
7. Start this example:

Expand Down
2 changes: 1 addition & 1 deletion examples/discovery-mechanisms/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const TCP = require('libp2p-tcp')
const Mplex = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
const PeerInfo = require('peer-info')
const Bootstrap = require('libp2p-railing')
const Bootstrap = require('libp2p-bootstrap')
const waterfall = require('async/waterfall')
const defaultsDeep = require('@nodeutils/defaults-deep')

Expand Down
2 changes: 1 addition & 1 deletion examples/echo/src/libp2p-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const TCP = require('libp2p-tcp')
const MulticastDNS = require('libp2p-mdns')
const WS = require('libp2p-websockets')
const Bootstrap = require('libp2p-railing')
const Bootstrap = require('libp2p-bootstrap')
const spdy = require('libp2p-spdy')
const KadDHT = require('libp2p-kad-dht')
const mplex = require('libp2p-mplex')
Expand Down
2 changes: 1 addition & 1 deletion examples/encrypted-communications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ And that's it, from now on, all your libp2p communications are encrypted. Try ru

If you want to want to learn more about how SECIO works, you can read the [great write up done by Dominic Tarr](https://github.com/auditdrivencrypto/secure-channel/blob/master/prior-art.md#ipfss-secure-channel).

Importante note: SECIO hasn't been audited and so, we do not recommend to trust its security. We intent to move to TLS 1.3 once the specification is finalized and an implementation exists that we can use.
Important note: SECIO hasn't been audited and so, we do not recommend to trust its security. We intent to move to TLS 1.3 once the specification is finalized and an implementation exists that we can use.
8 changes: 4 additions & 4 deletions examples/libp2p-in-the-browser/1/src/browser-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const defaultsDeep = require('@nodeutils/defaults-deep')
const libp2p = require('../../../../')

// Find this list at: https://github.com/ipfs/js-ipfs/blob/master/src/core/runtime/config-browser.json
const bootstrapers = [
const bootstrapList = [
'/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
'/dns4/sfo-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx',
'/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
Expand All @@ -20,8 +20,8 @@ const bootstrapers = [
'/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
'/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
'/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic',
'/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6'
'/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic',
'/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6'
]

class Node extends libp2p {
Expand Down Expand Up @@ -60,7 +60,7 @@ class Node extends libp2p {
bootstrap: {
interval: 10000,
enabled: true,
list: bootstrapers
list: bootstrapList
}
},
relay: {
Expand Down
14 changes: 7 additions & 7 deletions examples/libp2p-in-the-browser/1/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@ domReady(() => {
let connections = {}

node.on('peer:discovery', (peerInfo) => {
console.log('Discovered a peer')
const idStr = peerInfo.id.toB58String()
console.log('Discovered: ' + idStr)
if (connections[idStr]) {
// If we're already trying to connect to this peer, dont dial again
return
}
console.log('Discovered a peer:', idStr)

connections[idStr] = true
node.dial(peerInfo, (err, conn) => {
let timeToNextDial = 0
if (err) {
// Prevent immediate connection retries from happening
timeToNextDial = 30 * 1000
// and include a 10s jitter
const timeToNextDial = 25 * 1000 + (Math.random(0) * 10000).toFixed(0)
console.log('Failed to dial:', idStr)
setTimeout(() => delete connections[idStr], timeToNextDial)
}

setTimeout(() => delete connections[idStr], timeToNextDial)
})
})

Expand All @@ -49,8 +47,10 @@ domReady(() => {

node.on('peer:disconnect', (peerInfo) => {
const idStr = peerInfo.id.toB58String()
delete connections[idStr]
console.log('Lost connection to: ' + idStr)
document.getElementById(idStr).remove()
const el = document.getElementById(idStr)
el && el.remove()
})

node.start((err) => {
Expand Down

0 comments on commit ebcd3f6

Please sign in to comment.