-
Notifications
You must be signed in to change notification settings - Fork 481
refactor: ping #505
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: ping #505
Conversation
src/ping/handler.js
Outdated
* Subscribe ping protocol handler. | ||
* @param {Libp2p} node | ||
*/ | ||
function mount (node) { |
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.
@jacobheun what do you think about these namings?
I thought that we could make this more consistent with the transports and have a createListener
function or similar. But, I decided to gather your feedback first.
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 think mount/unmount is okay. We're not so much creating listeners as we are attaching an application protocol to libp2p. Different services/protocols may have different needs so keeping it generic might be good. If we ever create an interface for this type of service we could reevaluate this then.
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.
agreed
16d1cc0
to
7f7d7ea
Compare
7f7d7ea
to
25463e1
Compare
92c0bcd
to
c456834
Compare
c456834
to
e547009
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.
This looks great! Big improvement to the existing code 🎉. I left one minor comment.
Since the API docs have been merged, shall we add the docs for ping? Other than that, this LGTM.
src/index.js
Outdated
* @returns {Promise<number>} | ||
*/ | ||
async ping (peer) { | ||
const peerInfo = await getPeerInfoRemote(peer, 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.
I think we should just use getPeerInfo
for this, as ping really shouldn't support peers we don't know about locally. getPeerInfoRemote
will search the network if it can't find it locally.
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.
🚀 Looks good!
* refactor: ping * chore: ping is now a function * chore: address review
* refactor: ping * chore: ping is now a function * chore: address review
This PR refactors ping to use
async-it
instead ofpull-streams
Needs: