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

Expose offline conference peers in API #1266

Merged
merged 1 commit into from
Jan 5, 2019
Merged

Conversation

zugz
Copy link

@zugz zugz commented Nov 18, 2018

(based on #1156)


This change is Reviewable

Copy link

@sudden6 sudden6 left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 12 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @zugz)


toxcore/group.h, line 248 at r1 (raw file):

int del_groupchat(Group_Chats *g_c, uint32_t groupnumber);

/* Copy the public key of (frozen) peernumber who is in groupnumber to pk.

Took me quite some time to understand the meaning of (frozen) in conjunction with the function parameter, maybe add an explanation for this concept? Or maybe switch to (frozen/peer) number? maybe there are even better ways to name this.


toxcore/group.c, line 1090 at r1 (raw file):

    Group_Peer *list = frozen ? g->frozen : g->group;
    uint32_t num = frozen ? g->numfrozen : g->numpeers;

both can be const


toxcore/group.c, line 1115 at r1 (raw file):

    Group_Peer *list = frozen ? g->frozen : g->group;
    uint32_t num = frozen ? g->numfrozen : g->numpeers;

same


toxcore/group.c, line 1144 at r1 (raw file):

    Group_Peer *list = frozen ? g->frozen : g->group;
    uint32_t num = frozen ? g->numfrozen : g->numpeers;

same


toxcore/group.c, line 1168 at r1 (raw file):

                             uint64_t *last_active)
{
    Group_c *g = get_group_c(g_c, groupnumber);

const?


toxcore/group.c, line 1201 at r1 (raw file):

    }

    uint32_t num = frozen ? g->numfrozen : g->numpeers;

const


toxcore/group.c, line 1640 at r1 (raw file):

bool group_leave(const Group_Chats *g_c, uint32_t groupnumber)
{
    Group_c *g = get_group_c(g_c, groupnumber);

const


toxcore/tox.c, line 1536 at r1 (raw file):

{
    Messenger *m = tox->m;
    group_leave(m->conferences_object, conference_number);

check return value? if check not needed, why do we have a return value at all?


toxcore/tox.c, line 1650 at r1 (raw file):

{
    const Messenger *m = tox->m;
    int ret = group_number_peers(m->conferences_object, conference_number, true);

const? (similar cases down here)


toxcore/tox.api.h, line 2324 at r1 (raw file):

  }

  namespace offline_peer {

I'm a bit torn on the naming here, on one hand we call offline peers frozen internally but not externally which is a bit inconsistent, on the other hand frozen is not very descriptive for developers not familiar with Tox. What are your thoughts here?

@sudden6
Copy link

sudden6 commented Nov 29, 2018

So after save and load, the group numbers will be sequential. It's
arguable, but I think on balance this is better than preserving the
group numbers. Note that for the protocol it makes no difference - the
peer connections will go down, and so peers will update the group
numbers they have for us when we reconnect to that in our online packet.

Just to be 100% sure, this doesn't mean that after saving a running Tox instance all group numbers are invalid, right? Asking because qTox saves the *.tox on some actions but doesn't invalidate the group numbers.

@zugz
Copy link
Author

zugz commented Nov 29, 2018 via email

@codecov
Copy link

codecov bot commented Nov 29, 2018

Codecov Report

Merging #1266 into master will decrease coverage by 0.2%.
The diff coverage is 37.6%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1266     +/-   ##
========================================
- Coverage    83.3%   83.1%   -0.3%     
========================================
  Files          82      82             
  Lines       14869   14928     +59     
========================================
+ Hits        12394   12407     +13     
- Misses       2475    2521     +46
Impacted Files Coverage Δ
toxcore/state.c 66.6% <100%> (+2.5%) ⬆️
toxcore/group.c 78.3% <64.1%> (-0.5%) ⬇️
toxcore/tox.c 63.6% <9.3%> (-3.1%) ⬇️
toxcore/LAN_discovery.c 83% <0%> (-2.9%) ⬇️
toxcore/friend_connection.c 94.9% <0%> (-1.2%) ⬇️
toxcore/Messenger.c 86.8% <0%> (-0.2%) ⬇️
toxcore/net_crypto.c 94.9% <0%> (ø) ⬆️
toxcore/DHT.c 77.8% <0%> (ø) ⬆️
toxav/msi.c 64.8% <0%> (+0.2%) ⬆️
toxav/toxav.c 68.1% <0%> (+0.4%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebf3a82...a122ee9. Read the comment docs.

@sudden6
Copy link

sudden6 commented Nov 30, 2018

ok, that answers my questions.

Copy link
Author

@zugz zugz left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 approvals obtained (waiting on @sudden6)


toxcore/group.h, line 248 at r1 (raw file):

Previously, sudden6 wrote…

Took me quite some time to understand the meaning of (frozen) in conjunction with the function parameter, maybe add an explanation for this concept? Or maybe switch to (frozen/peer) number? maybe there are even better ways to name this.

How about "(possibly frozen) peernumber"?


toxcore/group.c, line 1090 at r1 (raw file):

Previously, sudden6 wrote…

both can be const

done


toxcore/group.c, line 1115 at r1 (raw file):

Previously, sudden6 wrote…

same

Done.


toxcore/group.c, line 1144 at r1 (raw file):

Previously, sudden6 wrote…

same

Done.


toxcore/group.c, line 1168 at r1 (raw file):

Previously, sudden6 wrote…

const?

Made it a TODO, since it's more appropriate for a separate PR.


toxcore/group.c, line 1201 at r1 (raw file):

Previously, sudden6 wrote…

const

Done.


toxcore/group.c, line 1640 at r1 (raw file):

Previously, sudden6 wrote…

const

as above


toxcore/tox.c, line 1536 at r1 (raw file):

Previously, sudden6 wrote…

check return value? if check not needed, why do we have a return value at all?

if we get an error here, we also get an error in del_groupchat on the next line. Checking both would make the code harder to read. So I think it's best to leave it as is. It still makes sense to have group_leave return bool, for consistency and because we might want to check it in some context in the future.


toxcore/tox.c, line 1650 at r1 (raw file):

Previously, sudden6 wrote…

const? (similar cases down here)

Again, made it a TODO


toxcore/tox.api.h, line 2324 at r1 (raw file):

Previously, sudden6 wrote…

I'm a bit torn on the naming here, on one hand we call offline peers frozen internally but not externally which is a bit inconsistent, on the other hand frozen is not very descriptive for developers not familiar with Tox. What are your thoughts here?

My thinking was that "offline" would be clearer to users of the library, but "frozen" is more descriptive of what's actually going on internally. So I kept "frozen" for tox-internal use, but made in "offline" in the API. If you really think it's too confusing, we could use "offline" everywhere. But in the context of the groups internals, this sounds like it should be about connections going down, which it isn't, and more generally there's the risk of confusion with the entirely separate concept of friend_connections being offline.

Copy link

@sudden6 sudden6 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 12 files at r1, 1 of 4 files at r2.
Reviewable status: 0 of 1 approvals obtained (waiting on @zugz)


toxcore/group.h, line 248 at r1 (raw file):

Previously, zugz (zugz) wrote…

How about "(possibly frozen) peernumber"?

now I'm unsure how this API works exactly, if frozen is false, it will only return online peers, if frozen is true it will return online and frozen or frozen only?


toxcore/tox.c, line 1536 at r1 (raw file):

Previously, zugz (zugz) wrote…

if we get an error here, we also get an error in del_groupchat on the next line. Checking both would make the code harder to read. So I think it's best to leave it as is. It still makes sense to have group_leave return bool, for consistency and because we might want to check it in some context in the future.

after a quick glance I could not find another use of group_leave maybe merge it into `del_groupchat´ to avoid this problem and simplify the code?


toxcore/tox.api.h, line 2324 at r1 (raw file):

Previously, zugz (zugz) wrote…

My thinking was that "offline" would be clearer to users of the library, but "frozen" is more descriptive of what's actually going on internally. So I kept "frozen" for tox-internal use, but made in "offline" in the API. If you really think it's too confusing, we could use "offline" everywhere. But in the context of the groups internals, this sounds like it should be about connections going down, which it isn't, and more generally there's the risk of confusion with the entirely separate concept of friend_connections being offline.

After sleeping a few nights over this, I fully agree with your PoV. Externally it would be pretty confusing for user of the library to talk about frozen peers.

Copy link

@sudden6 sudden6 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 12 files at r1.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @zugz)

Copy link
Author

@zugz zugz left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 approvals obtained (waiting on @sudden6)


toxcore/group.h, line 248 at r1 (raw file):

Previously, sudden6 wrote…

now I'm unsure how this API works exactly, if frozen is false, it will only return online peers, if frozen is true it will return online and frozen or frozen only?

Frozen only. How about "(frozen, if frozen is true) peernumber"? I hope that's clear?


toxcore/tox.c, line 1536 at r1 (raw file):

Previously, sudden6 wrote…

after a quick glance I could not find another use of group_leave maybe merge it into `del_groupchat´ to avoid this problem and simplify the code?

It's used elsewhere too in #1267.

@sudden6
Copy link

sudden6 commented Dec 2, 2018


toxcore/group.h, line 248 at r1 (raw file):

Previously, zugz (zugz) wrote…

Frozen only. How about "(frozen, if frozen is true) peernumber"? I hope that's clear?

yeah, that's pretty clear

@sudden6
Copy link

sudden6 commented Dec 2, 2018


toxcore/tox.c, line 1536 at r1 (raw file):

Previously, zugz (zugz) wrote…

It's used elsewhere too in #1267.

Also there it's immediately followed by a call to del_groupchat

@zugz
Copy link
Author

zugz commented Dec 2, 2018 via email

@zugz
Copy link
Author

zugz commented Dec 2, 2018 via email

Copy link

@sudden6 sudden6 left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

Reviewed 3 of 3 files at r3.
Reviewable status: 0 of 1 approvals obtained

@zugz zugz force-pushed the confFrozenAPI branch 2 times, most recently from 012ca95 to 155bfd1 Compare December 2, 2018 15:50
@iphydf iphydf force-pushed the confFrozenAPI branch 3 times, most recently from 2117bd8 to 388942d Compare January 3, 2019 11:28
/**
* Error codes for peer info queries.
*/
error for query {
Copy link
Member

Choose a reason for hiding this comment

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

error for peer.query can be reused (I hope that there is a syntax for that that works).

@iphydf iphydf merged commit a122ee9 into TokTok:master Jan 5, 2019
@iphydf iphydf removed this from the v0.2.x milestone Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants