Hugo Dias 9b13fe321a
fix: remove node global (#587)
* fix: use new libp2p-crypto

* fix: remove node globals and reduce size

- adds buffer require
- adds globalThis where needed
- streaming-iterables was remove and new utils created, this will be consolidated in `ipfs-utils` and backported here to normalize all these iterator helper functions
- latency-monitor was copied inside the repo
- iso-random-stream is now used instead of node crypto
- the test `should ignore self on discovery` was moved to node only

Size: 172.97KB
47.03KB below the 220KB limit.

`aegir build --node false` and `aegir test -t browser --node false` now work 🎉

* fix: fix require path

* fix: feedback

* fix: update deps and bundle size

* chore: bump interfaces

* chore: update size
2020-04-24 17:10:40 +02:00
..
2020-01-24 14:40:40 +01:00
2020-04-24 17:10:40 +02:00
2020-01-24 14:40:40 +01:00
2020-01-24 14:40:40 +01:00
2020-01-24 14:40:40 +01:00
2020-01-24 14:40:40 +01:00

Private Networking

This example shows how to set up a private network of libp2p nodes.

Setup

Install dependencies:

npm install

Run

Running the example will cause two nodes with the same swarm key to be started and exchange basic information.

node index.js

Using different keys

This example includes TASK comments that can be used to try the example with different swarm keys. This will allow you to see how nodes will fail to connect if they are on different private networks and try to connect to one another.

To change the swarm key of one of the nodes, look through index.js for comments starting with TASK to indicate where lines are that pertain to changing the swarm key of node 2.

Exploring the repos

Once you've run the example you can take a look at the repos in the ./tmp directory to see how they differ, including the swarm keys. You should see a swarm.key file in each of the repos and when the nodes are on the same private network this contents of the swarm.key files should be the same.