Connect with nim-waku node

This commit is contained in:
Oskar Thoren
2020-09-21 13:09:35 +08:00
parent 3149e41845
commit 5ad921244d
2 changed files with 39 additions and 0 deletions

View File

@@ -43,3 +43,21 @@ See patches folder for current hacks to get basic interop with nim-waku.
If there are problems applying them, comment out `postinstall` in
`package.json`.
## Interop with nim-waku
Go to https://github.com/status-im/nim-waku/ and build `wakunode2`.
Then run it:
```
./build/wakunode2 --ports-shift:0
```
Note the "Listening on" address in logs. E.g. `/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmVKynP3QDpjxS2gujvy2Bp3BEKp8NzKmYspxDEVAGHftG`.
Call nodejs node with it as argument:
``` sh
node index.js /ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmVKynP3QDpjxS2gujvy2Bp3BEKp8NzKmYspxDEVAGHftG
```

View File

@@ -20,9 +20,12 @@ const MDNS = require('libp2p-mdns')
const KadDHT = require('libp2p-kad-dht')
// PubSub implementation
const Gossipsub = require('libp2p-gossipsub')
// Multiaddress
const multiaddr = require('multiaddr')
;(async () => {
// Create the Node
//
const libp2p = await Libp2p.create({
addresses: {
listen: [
@@ -67,6 +70,24 @@ const Gossipsub = require('libp2p-gossipsub')
// Start libp2p
await libp2p.start()
console.log('listening on addresses:')
libp2p.multiaddrs.forEach(addr => {
console.log(`${addr.toString()}/p2p/${libp2p.peerId.toB58String()}`)
})
console.log('\nNode supports protocols:')
libp2p.upgrader.protocols.forEach((_, p) => console.log(p))
const codec = "/vac/waku/relay/2.0.0-beta1"
// Dial nim-waku
if (process.argv.length >= 3) {
const ma = multiaddr(process.argv[2])
console.log(`dialing remote peer at ${process.argv[2]}`)
await libp2p.dialProtocol(ma, codec)
console.log(`dialed ${process.argv[2]}`)
}
// Create our PubsubChat client
const pubsubChat = new PubsubChat(libp2p, PubsubChat.TOPIC, ({ from, message }) => {
let fromMe = from === libp2p.peerId.toB58String()