nwaku/examples/v2
Alvaro Revuelta 43fd11b4dc
refactor: reuse nim-libp2p peerstore + move peermanager logic (#1383)
* refactor: reuse nim-libp2p peerstore + move peermanager logic

* refactor: fix comments

* refactor: modify reconnectPeers and unittest

* feat(apps): new flag for peerStoreCapacity

* fix(examples): fix example2 target

* refactor: fix comments
2022-11-24 14:11:23 +01:00
..
README.md chore(examples): add pubsub example with production env (#1333) 2022-11-04 13:40:24 +01:00
basic2.nim chore: rename protocols rpc_codec procs from init to decode 2022-11-07 16:24:16 +01:00
example_config.toml feat(config): add config file support (#953) 2022-05-17 17:48:08 +02:00
nim.cfg chore: build rln dependecies only when building v2 2022-11-07 09:14:21 +01:00
publisher.nim refactor: reuse nim-libp2p peerstore + move peermanager logic (#1383) 2022-11-24 14:11:23 +01:00
subscriber.nim refactor: reuse nim-libp2p peerstore + move peermanager logic (#1383) 2022-11-24 14:11:23 +01:00

README.md

# basic2

TODO

# publisher/subscriber

Within examples/v2 you can find a publisher and a subscriber. The first one publises messages to the default pubsub topic to a given content topic, and the second one runs forever listening to that pubsub topic and printing the content it receives.

Some notes:

  • These examples are meant to work even in if you are behind a firewall and you can't be discovered by discv5.
  • You only need to provide a reachable bootstrap peer (see our fleets)
  • The examples are meant to work out of the box.
  • Note that both services wait for some time until a given minimum amount of connections are reached. This is to ensure messages are gossiped.

Compile:

Make all examples.

make example2

Run:

Wait until the subscriber is ready.

./build/subscriber

And run a publisher

./build/publisher

See how the subscriber received the messages published by the publisher. Feel free to experiment from different machines in different locations.