You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Use PowerShell, Command Prompt, or Git Bash as your shell.
196
+
- Ensure all tools (Python, Git, CMake) are in your system PATH.
66
197
67
198
Requirements
68
199
^^^^^^^^^^^^
@@ -110,6 +241,47 @@ Good documentation will lead to quicker adoption and happier users. Please check
110
241
guide on
111
242
`how to create documentation for the Python Ethereum ecosystem <https://github.com/ethereum/snake-charmers-tactical-manual/blob/main/documentation.md>`_.
112
243
244
+
Adding Examples
245
+
~~~~~~~~~~~~~~~
246
+
247
+
To add a new example (e.g., identify):
248
+
249
+
1. Create a directory in ``examples/identify``
250
+
2. Create a file ``examples/identify/identify.py`` with the example code
251
+
3. Add ``__init__.py`` to make it a proper Python package (automatically discovered by find_packages() in ``setup.py``)
252
+
4. Add the example in the example list ``docs/examples.rst``
253
+
5. Add example tests in ``tests/core/examples/test_examples.py``
254
+
6. Add the example documentation in ``docs/examples.identify.rst``
255
+
7. Add a news fragment for the new release in file ``newsfragments/536.feature.rst`` (fix-id.type.rst)
256
+
8. Generate doc files with ``make docs`` or ``make linux-docs`` in linux (generates files ``libp2p.identity.identify.rst libp2p.identity.rst libp2p.identity.identify.pb.rst``)
257
+
9. Add the example to ``setup.py``:
258
+
259
+
.. code:: python
260
+
261
+
entry_points={
262
+
"console_scripts": [
263
+
"chat-demo=examples.chat.chat:main",
264
+
"echo-demo=examples.echo.echo:main",
265
+
"ping-demo=examples.ping.ping:main",
266
+
"identify-demo=examples.identify.identify:main",
267
+
],
268
+
}
269
+
270
+
10. Run ``make package-test`` to test the release:
271
+
272
+
.. code:: sh
273
+
274
+
.....
275
+
Activate with `source /tmp/tmpb9ybjgtg/package-smoke-test/bin/activate`
276
+
Press enter when the test has completed. The directory will be deleted.
2025-04-07 00:00:59,846 - pubsub-demo - INFO - Your selected topic is: pubsub-chat
36
+
2025-04-07 00:00:59,846 - pubsub-demo - INFO - Using random available port: 51977
37
+
2025-04-07 00:00:59,864 - pubsub-demo - INFO - Node started with peer ID: QmYQKCm95Ut1aXsjHmWVYqdaVbno1eKTYC8KbEVjqUaKaQ
38
+
2025-04-07 00:00:59,864 - pubsub-demo - INFO - Listening on: /ip4/0.0.0.0/tcp/51977
39
+
2025-04-07 00:00:59,864 - pubsub-demo - INFO - Initializing PubSub and GossipSub...
40
+
2025-04-07 00:00:59,864 - pubsub-demo - INFO - Pubsub and GossipSub services started.
41
+
2025-04-07 00:00:59,865 - pubsub-demo - INFO - Pubsub ready.
42
+
2025-04-07 00:00:59,865 - pubsub-demo - INFO - Subscribed to topic: pubsub-chat
43
+
2025-04-07 00:00:59,866 - pubsub-demo - INFO - Connecting to peer: QmcJnocH1d1tz3Zp4MotVDjNfNFawXHw2dpB9tMYGTXJp7 using protocols: MultiAddrKeys(<Multiaddr /ip4/127.0.0.1/tcp/33269/p2p/QmcJnocH1d1tz3Zp4MotVDjNfNFawXHw2dpB9tMYGTXJp7>)
44
+
2025-04-07 00:00:59,866 - pubsub-demo - INFO - Run this script in another console with:
2025-04-07 00:00:59,881 - pubsub-demo - INFO - Connected to peer: QmcJnocH1d1tz3Zp4MotVDjNfNFawXHw2dpB9tMYGTXJp7
48
+
Type messages to send (press Enter to send):
49
+
50
+
You can then start typing messages in either terminal and see them relayed to the other terminal. The messages will be distributed using the GossipSub protocol to all peers subscribed to the same topic. To exit the demo, type "quit" or send a keyboard interrupt (``Ctrl+C``) in either terminal.
51
+
52
+
Command Line Options
53
+
--------------------
54
+
55
+
- ``-t, --topic``: Specify the topic name to subscribe to (default: "pubsub-chat")
56
+
- ``-d, --destination``: Address of peer to connect to
57
+
- ``-p, --port``: Port to listen on (default: random available port)
0 commit comments