Skip to content
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

Updated pinging logic. #289

Merged
merged 8 commits into from May 31, 2019
Merged

Updated pinging logic. #289

merged 8 commits into from May 31, 2019

Conversation

Mikunj
Copy link

@Mikunj Mikunj commented May 24, 2019

There were a few minor cases that we were missing when checking whether we should ping or just mark the user as online.

This PR simplifies that logic down according to the following diagram:
Screen Shot 2019-05-24 at 11 41 07 am

EDIT: The image is missing a connection between Was a user marked as online before? and Ping contact

Here we assume:

  1. When pinging, if it succeeds then we set contact to online
  2. When we mark the contact as online then we reset their ping timers
  3. We always save the latest details

Copy link

@sachaaaaa sachaaaaa left a comment

Choose a reason for hiding this comment

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

So is it correct to say that we used to display a contact as online as soon as we received a p2p message from them, while now it can only result from a ping?

const contactDetails = this.contactP2pDetails[pubKey];
return !!(contactDetails && contactDetails.isOnline);
if (!this.contactP2pDetails[pubKey]) return null;
return { ...this.contactP2pDetails[pubKey] };

Choose a reason for hiding this comment

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

Was this returning a reference instead of a copy?
If so, good catch.

Choose a reason for hiding this comment

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

Ya, don't think it was affecting the actual functionality but it was picked up by the tests

@Mikunj
Copy link
Author

Mikunj commented May 27, 2019

So is it correct to say that we used to display a contact as online as soon as we received a p2p message from them, while now it can only result from a ping?

Ye, now we only mark the contact is online if our p2p handshake went through successfully.

@BeaudanBrown BeaudanBrown merged commit 1e11a65 into oxen-io:development May 31, 2019
@Mikunj Mikunj deleted the p2p-ping branch September 11, 2019 05:28
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.

None yet

3 participants