-
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: fallback to floodsub #34
feat: fallback to floodsub #34
Conversation
Codecov Report
@@ Coverage Diff @@
## master #34 +/- ##
==========================================
+ Coverage 83.22% 84.86% +1.64%
==========================================
Files 8 8
Lines 453 489 +36
==========================================
+ Hits 377 415 +38
+ Misses 76 74 -2
Continue to review full report at Codecov.
|
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.
Added some minor language changes, but the major thing is updating the dial logic so we don't accidentally use floodsub if gossip is usable.
src/pubsub.js
Outdated
* @returns {void} | ||
*/ | ||
_dialPeer (peerInfo, callback) { | ||
const onDial = (idB58Str, pubsubStopped, conn) => { |
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.
I'm not sure I understand the purpose of this function wrapper for _onDial
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.
I moved the logic to the _onDial
function.
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.
This LGTM. We can improve the dialPeer logic in a later PR once we add support for dialBest
or similar in libp2p.
@wemeetagain @Mikerah @GregTheGreek can you have a look and merge this PR if you approve it? |
Hey sorry, I'm on it, I know @wemeetagain Is a bit under the weather |
Co-Authored-By: Jacob Heun <[email protected]>
Co-Authored-By: Jacob Heun <[email protected]>
f000cbb
to
fc9f13a
Compare
src/pubsub.js
Outdated
@@ -186,6 +269,10 @@ class BasicPubSub extends Pubsub { | |||
if (err) { | |||
return callback(err) | |||
} | |||
// if fallback to floodsub enabled, we need to listen to its protocol | |||
if (this._options.fallbackToFloodsub) { | |||
this.libp2p.handle('/floodsub/1.0.0', this._onConnection) |
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.
consider pulling out the string into a constant.
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.
wait sorry! I will change it, I already have the constant 😅
Should be ready now @wemeetagain |
Thanks ❤️ |
Added a fallback to dial with other peers running floodsub, behind an option.
For this context, the
_dialPeer
function was override fromlibp2p-pubsub
to extend the dial behavior with the selection of the appropriate protocol to dial .