Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cbindings): tiny waku relay example in Python #1793

Merged
merged 4 commits into from
Jul 31, 2023

Conversation

Ivansete-status
Copy link
Collaborator

@Ivansete-status Ivansete-status commented Jun 12, 2023

Description

Nwaku integration library (libwaku.so) in Python

Changes

  • Adding new waku.py that shows an example on how to integrate nwaku (libwaku.so) in Python.
  • libwaku.nim: adapting code to latest changes made in 34a9263

How to test

  1. Open a terminal in the root folder and run the next (python3 should be installed beforehand:)
    python3 examples/python/waku.py -p 60000 -k 364d111d729a6eb6d2e6113e163f017b5ef03a6f94c9b5b7bb1bb36fa5cb07a9 -r 1
    
  2. Open a second terminal window and run the next from within the repo's root folder:
    ./build/wakunode2 --config-file=cfg_node_b.txt
    
    cfg_node_b.txt
  3. Open a third terminal and run:
    while [ true ]; do curl -d "{\"jsonrpc\":\"2.0\",\"id\":"$(date +%s)",\"method\":\"post_waku_v2_relay_v1_message\", \"params\":[\"/waku/2/default-waku/proto\", {\"timestamp\":"$(date +%s)", \"payload\":\"VGhpcyBpcyBhIG1lc3NhZ2UK\"}]}" --header "Content-Type: application/json" http://localhost:8546; done
    

At this stage, in the first terminal (python) there should appear sth like:
Event received: b'{"pubsubTopic":"/waku/2/default-waku/proto","messageId":"TODO","wakuMessage":{"payload":"This is a message\\n","contentTopic":"/waku/2/default-content/proto","version":0,"timestamp":1686582003},"eventType":"message"}'

Issue

#1632

@Ivansete-status Ivansete-status marked this pull request as ready for review June 12, 2023 15:08
@Ivansete-status Ivansete-status self-assigned this Jun 12, 2023
Copy link
Contributor

@rymnc rymnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@Ivansete-status Ivansete-status force-pushed the feat-1632-relay-python branch from 4ee0a5d to 777ce03 Compare July 31, 2023 15:06
@Ivansete-status Ivansete-status merged commit 0b2cfae into master Jul 31, 2023
@Ivansete-status Ivansete-status deleted the feat-1632-relay-python branch July 31, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants