-
Notifications
You must be signed in to change notification settings - Fork 43
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: self emit option #40
Conversation
Out of curiosity, what is the use case for emitting to self? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Quoting @jacobheun
So, for example a real time dapp would benefit from publishing data, and it appears on the UI, through the same handler where it receives messages from the other peers. |
Thats very curious |
I am unsure of the actual intent for originally doing this, it's an assumption I made for the use case for users. I'd personally prefer to just take it out as part of moving pubsub out of experimental (alongside the gossipsub support release of libp2p), but there are potential impacts to end users, which is what this PR aims to avoid. Since the config is changing we could remove it from floodsub and just be clear about this in the docs and release notes for libp2p. |
Might be worth reaching out to people whom are using the package to see if it causes a headache first? I know the go libp2p did a change that broke a fair bit of stuff a few weeks ago, happy to take this one slowly |
So @jacobheun in your opinion, we default to I think that taking into account the breaking change we will do in |
Also, this affects |
I think the right thing to do is to make it compatible with how it is now, as this PR proposes, and then try to move away from it after some community discussion. I'd rather have this in there and get Gossipsub out without needing to worry about this level of implementation detail. |
makes sense to me - we'll wait for @wemeetagain review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we're currently relying on emitSelf being false.
Somewhat unrelated, I think we'll want to be able to also control when we forward messages in the future. Right now, we auto-forward received messages in subscribed topics, but we will also want to switch that off.
6003898
40a6c18
to
6003898
Compare
6003898
to
bf17585
Compare
Codecov Report
@@ Coverage Diff @@
## master #40 +/- ##
==========================================
- Coverage 85.45% 83.82% -1.64%
==========================================
Files 8 8
Lines 495 513 +18
==========================================
+ Hits 423 430 +7
- Misses 72 83 +11
Continue to review full report at Codecov.
|
Rebased the PR after the message validation PR got merged. I think this is good to go Merge #39 previously than this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Bumps [aegir](https://github.com/ipfs/aegir) from 20.6.1 to 21.2.0. - [Release notes](https://github.com/ipfs/aegir/releases) - [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md) - [Commits](ipfs/aegir@v20.6.1...v21.2.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
I found a behavioral inconsistency between the
libp2p-floodsub
implementation and this implementation.In
libp2p-floodsub
, when a peer A subscribes a topic, if that same peer A publishes for that topic, the topic is also emitted to self, which does not happen in this implementation. I added this behavior behind a flag, which defaults tofalse
right now, in order to keep the behavior you previously added. I chosefalse
for now, as you had tests that verified if the self was not emitted to self.In
libp2p-floodsub
we currently do emit to self all the times. I also agree that there are several use cases, where we may not want that, and in this context, I will also add this option inlibp2p-floodsub
.I will open an issue on libp2p/js-libp2p-pubsub for discussing which should be the default behavior from
js-libp2p
users, as I discussed this previously with @jacobheun . If you have no reason to not do this emit self by default, I would prefer to set it true for now in this PR, as we do infloodsub
(will be a breaking change!). Otherwise, I will make it true by default fromjs-libp2p
, until we decide if we should turn it into afalse
default.NOTE: This PR also contains #39 commits, as I want to use this branch for testing the integration with
js-ipfs
. So, once #39 is merged, those 2 extra commits will be removed.