You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
raven/README.md

64 lines
2.5 KiB
Markdown

6 years ago
# libp2p Demos
6 years ago
## Demo 1: DHT Peer & Content with Go and JS Nodes
6 years ago
**Directory**: `content-dht-provide-find`
**What it demonstrates:** A new DHT is created by the Go program `dht-interop`. In a separate terminal or machine, a Node.js program connects to this DHT. One connected, each verifies that it can find the other's content via the DHT.
6 years ago
**First terminal:**
```
cd content-dht-provide-find
make
./dht-interop -b ../util/private_key.bin.bootstrapper.Wa
6 years ago
```
`-b` means bootstrap mode. In this example, the go program is always the bootstrap node, so `-b` is always required.
Note that the node ID of `dht-interop` is always `Qm...6aJ9oRuEzWa` because it is being read in from `../util/private_key.bin.bootstrapper.Wa` (a private key marshalled to X.509 generated by the program `util/private-key-gen`). This is to keep the peer id of the bootstrap server stable across invocations.
6 years ago
**Second terminal:** run the command printed out by dht-interop, replacing 127.0.0.1 with the IP of the server where dht-interop is listening. Example:
6 years ago
Running the Node.js program:
6 years ago
```
cd content-dht-provide-find/js-dht-test
npm install # first time only
6 years ago
node js-dht-test/index.js /ip4/127.0.0.1/tcp/9876/ipfs/QmehVYruznbyDZuHBV4vEHESpDevMoAovET6aJ9oRuEzWa
```
## Demo 2: PubSub
6 years ago
**Directory**: `pubsub`
6 years ago
**What it demonstrates**: Two Go nodes are created and run a chat server using a shared PubSub topic. **TODO**: Should be a Go node and a JS node, once I get the two Go nodes version working.
**First terminal**: Create the bootstrapper node
```
cd pubsub
./pubsub-interop -b ../util/private_key.bin.bootstrapper.Wa
```
The bootstrapper creates a new libp2p node, subscribes to the shared topic string, spawns a go routine to emit any publishes to that topic, and then waits forever.
**Second terminal**: Create a go peer to connect to bootstrapper and publish on the topic
```
cd pubsub
./pubsub-interop ../util/private_key.bin.peer.Sk
```
This peer, which is not in bootstrapper mode, creates a node, subscribes to the shared topic string, spawns the same go routine, and then loops forever requesting user input and publishing each line to the topic.
#TODO
**Third terminal**: Create a JS peer to connect to bootstrap and publish on topic
```
cd pubsub/js
npm install # first time only
node index.js /ip4/127.0.0.1/tcp/9876/ipfs/QmehVYruznbyDZuHBV4vEHESpDevMoAovET6aJ9oRuEzWa
```
6 years ago
_Acknowledgements: @jhiesey for DHT (content & peer routing) JS+Go interop, @stebalien for PubSub_