Skip to content

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

Merged
merged 3 commits into from
Dec 10, 2019
Merged

refactor: ping #505

merged 3 commits into from
Dec 10, 2019

Conversation

vasco-santos
Copy link
Member

@vasco-santos vasco-santos commented Dec 10, 2019

This PR refactors ping to use async-it instead of pull-streams

Needs:

* Subscribe ping protocol handler.
* @param {Libp2p} node
*/
function mount (node) {
Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed

@vasco-santos vasco-santos force-pushed the refactor/ping branch 2 times, most recently from 16d1cc0 to 7f7d7ea Compare December 10, 2019 13:55
@vasco-santos vasco-santos changed the base branch from feat/token-dialer to refactor/async-await December 10, 2019 14:41
Copy link
Contributor

@jacobheun jacobheun left a 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)
Copy link
Contributor

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.

Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

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

🚀 Looks good!

@jacobheun jacobheun merged commit 88e5698 into refactor/async-await Dec 10, 2019
@jacobheun jacobheun deleted the refactor/ping branch December 10, 2019 18:26
jacobheun pushed a commit that referenced this pull request Dec 12, 2019
* refactor: ping

* chore: ping is now a function

* chore: address review
jacobheun pushed a commit that referenced this pull request Jan 24, 2020
* refactor: ping

* chore: ping is now a function

* chore: address review
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.

2 participants