Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

new generation login_id #34

Open
k-morozov opened this issue Jul 6, 2020 · 7 comments
Open

new generation login_id #34

k-morozov opened this issue Jul 6, 2020 · 7 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects

Comments

@k-morozov
Copy link
Owner

new generation login_id

@k-morozov k-morozov added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Jul 6, 2020
@k-morozov k-morozov self-assigned this Jul 6, 2020
@k-morozov
Copy link
Owner Author

Need to rewrite the login_id generation logic

@ashishsiyag
Copy link

@k-morozov I read your code and logic you have used for login_id is starting from value 0 and incrementing it as new client logs in, right?

@k-morozov
Copy link
Owner Author

@ashishsiyag Yes. A new client_id is generated for a new client (starting from 0, increasing by 1). This is a bad solution because when server is restarting - for all new clients will be generated client_id starting from 0. The solution (as I think):

  1. generating id on a 32 bit random number (and check that it's unique).
    or .
  2. Save the counter information for id in the database.

@ashishsiyag
Copy link

ashishsiyag commented Sep 3, 2020

@k-morozov We can choose a hash function to generate the 32-bit client_id for the new client, for checking whether the id generated is unique or not, we need to store client_id and check whether the id exists or not.
Do you have any constraints on id generation?

@k-morozov
Copy link
Owner Author

k-morozov commented Sep 4, 2020

@ashishsiyag variable size only. usnigned number.

@ashishsiyag
Copy link

@k-morozov more of whether the operation need to be O(1) or O(logn) will do? To check whether the key exists we need to look through the previous keys, if we directly store them into database and check whether it exists or not, will take O(logn).

@k-morozov
Copy link
Owner Author

@ashishsiyag If you can implement complexity O(1) - excellent.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
AppChat
Awaiting triage
Development

No branches or pull requests

2 participants