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: example using filter and lightpush #1720

Merged
merged 3 commits into from
May 12, 2023

Conversation

jm-clius
Copy link
Contributor

@jm-clius jm-clius commented May 5, 2023

While working on testing the new filter protocol, I realised that it will have some value to package a lightpush publisher and filter subscriber as an example.

I've tried to keep to the spirit of the current subscriber-publisher example, but without adding to our current MAKE targets.

@jm-clius jm-clius changed the title Example using filter and lightpush feat: example using filter and lightpush May 5, 2023
@jm-clius jm-clius force-pushed the feat/filter-lightpush-example branch from 1695e4c to 928e32e Compare May 5, 2023 11:16
Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

It does look great! Thanks for this PR!

examples/v2/filter_subscriber.nim Outdated Show resolved Hide resolved
examples/v2/filter_subscriber.nim Outdated Show resolved Hide resolved
Comment on lines +77 to +78
asyncSpawn maintainSubscription(wfc, filterPeer, FilterPubsubTopic, FilterContentTopic)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just for my understanding, in which cases we should use asyncSpawn ? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this is to dispatch a future without awaiting its result. However, if you simply discard the future it may contain errors which gets "swallowed". For that reason, you should always use asyncSpawn, which will convert any error in the future to a Defect. See https://github.com/status-im/nim-chronos/blob/8563c936733a28bc1e773542e9741b5b55dfcaeb/chronos/asyncloop.nim#L130-L137

jm-clius and others added 2 commits May 12, 2023 10:05
Co-authored-by: Ivan Folgueira Bande <128452529+Ivansete-status@users.noreply.github.com>
Co-authored-by: Ivan Folgueira Bande <128452529+Ivansete-status@users.noreply.github.com>
Copy link
Contributor

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

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

great example! super useful!

@jm-clius jm-clius merged commit 8987d4a into master May 12, 2023
@jm-clius jm-clius deleted the feat/filter-lightpush-example branch May 12, 2023 10:35
@vpavlin vpavlin mentioned this pull request May 16, 2023
1 task
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.

3 participants