-
Notifications
You must be signed in to change notification settings - Fork 453
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
refactor: pubsub #467
refactor: pubsub #467
Conversation
0fb7dc1
to
09cae28
Compare
09cae28
to
d5aba97
Compare
d5aba97
to
692f6a6
Compare
692f6a6
to
4be379e
Compare
0158558
to
221f613
Compare
|
||
peers: promisify((topic, callback) => { | ||
getPeersSubscribed: (topic) => { |
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.
Would we ever have pubsub peers that aren't subscribed, if so, are those different? Just trying to get a better understanding of what this is expected to return. Might be good to add some jsdocs to the methods missing them.
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.
We can have peers connected with pubsub, but that did not subscribe the topic provided.
I will add jsdocs here and more concrete stuff like examples in the docs PR
959c4ad
to
9b68696
Compare
b48661e
to
3355780
Compare
3355780
to
4cc9736
Compare
test/pubsub/operation.node.js
Outdated
}) | ||
|
||
// TODO: Needs identify push | ||
describe.skip('pubsub started after connect', () => { |
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 suite should be able to be run now.
test/registrar/registrar.spec.js
Outdated
} | ||
throw new Error('should fail to register a protocol if the onDisconnect handler is not provided') | ||
}) | ||
// TODO: not valid topology |
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.
Did you want to add something for this?
src/upgrader.js
Outdated
@@ -186,7 +186,7 @@ class Upgrader { | |||
const { stream, protocol } = await mss.handle(Array.from(this.protocols.keys())) | |||
log('%s: incoming stream opened on %s', direction, protocol) | |||
connection.addStream(stream, protocol) | |||
this._onStream({ connection, stream, protocol }) | |||
this._onStream({ connection, stream, protocol, remotePeer }) |
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.
There shouldn't be a need to pass the remotePeer
, as it's on the connection, connection.remotePeer
. Same with the other two changes below
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.
1 minor thing with the Topology check, otherwise this looks good
src/registrar.js
Outdated
assert( | ||
Topology.isTopology(topology) || | ||
MulticodecTopology.isMulticodecTopology(topology), | ||
'topology must be an instance of interfaces/topology') |
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.
is-class
should handle the base class extension check, so we should just need to check that it is a Topology, Topology.isTopology(topology)
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.
Cool, that works :)
1ca2d87
to
b33aca0
Compare
b33aca0
to
6240dc0
Compare
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.
🚀
* feat: peer-store v0 * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <[email protected]> * chore: address review * refactor: pubsub subsystem * chore: address review * chore: use topology interface * chore: address review * chore: address review * chore: simplify tests
* feat: peer-store v0 * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <[email protected]> * chore: address review * refactor: pubsub subsystem * chore: address review * chore: use topology interface * chore: address review * chore: address review * chore: simplify tests
* feat: peer-store v0 * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <[email protected]> * chore: address review * refactor: pubsub subsystem * chore: address review * chore: use topology interface * chore: address review * chore: address review * chore: simplify tests
* feat: peer-store v0 * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <[email protected]> * chore: address review * refactor: pubsub subsystem * chore: address review * chore: use topology interface * chore: address review * chore: address review * chore: simplify tests
This PR aims to add the pubsub subsystem into
js-libp2p
.In order to make it possible, the
peer-store
was created, as well as theregistrar
.The
peer-store
will replacepeer-book
, using the same name asgo-libp2p
, being this the initial step for libp2p/js-libp2p#453, as well as for the new version ofpeer-store
, which we will be working on after the refactor.The
registrar
aims to be a bridge between all subsystems andjs-libp2p
(peer-store
+connection-manager
). Before this refactor,js-libp2p
subsystems likepubsub
anddht
were responsible for tracking new peers that appear in the network and try to dial them using their respective protocols. Other than that, each subsystem was responsible for managing the connections and dials they were doing. This way, we aim to centralize this logic and enable subsystems to only care about their work, and leave the dialing and connection management for who should take care of them. It is also important pointing out that this is the first step to enable us to enhance theconnection-manager
. More context on libp2p/notes#13Needs: