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

uuid1_clockseq() #10

Closed
nviennot opened this issue Nov 13, 2015 · 2 comments
Closed

uuid1_clockseq() #10

nviennot opened this issue Nov 13, 2015 · 2 comments

Comments

@nviennot
Copy link

On the following snippet: https://github.com/zyro/elixir-uuid/blob/master/lib/uuid.ex#L440-L448
It seems that the whole thing is equivalent to :crypto.rand_bytes(2) (well, the first 14 bits) since the random generator is reseeded at every call, so there is no sequencing going on. Is this a problem?

@zyro
Copy link
Owner

zyro commented Nov 14, 2015

From section 4.1.5. of the RFC:

If the previous value of the clock sequence is known, it can just be incremented; otherwise it should be set to a random or high-quality pseudo-random value.

So a random clock sequence is OK. Alternatively UUID.uuid1/3 takes a clock sequence and node values, so the application can choose to track the previous ones if this is needed.

@nviennot
Copy link
Author

In that case, uuid1_clockseq() can be implemented with just a call to rand_bytes(2) ? Otherwise, the code seems a bit deceptive.

@zyro zyro closed this as completed in d3adc05 Nov 14, 2015
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

No branches or pull requests

2 participants