stephenc / eaio-uuid

Fork of eaio-uuid
http://stephenc.github.com/eaio-uuid/
Other
30 stars 26 forks source link

Implementation of the time-based UUID #3

Open arichiardi opened 10 years ago

arichiardi commented 10 years ago

Hello Stephen, I was looking at your implementation of the version 1 (time-based) UUID and I had a read of the RFC4122. I was interested in using your library but I think it still requires some work (at the moment I can't help you with it I am sorry). My idea was to keep the other two "shared state" described below in memory (with the possibility to store it to disk) together with what you already have:

From a system-wide shared stable store (e.g., a file), read the
UUID generator state: the values of the timestamp, clock sequence,
and node ID used to generate the last UUID.

So three fields instead of one. It would be great to have the possibility to completely skip the MAC polling and get a pseudo-random sequence as described below:

The exact algorithm to generate a node ID using these data is system
specific, because both the data available and the functions to obtain
them are often very system specific.  A generic approach, however, is
to accumulate as many sources as possible into a buffer, use a
message digest such as MD5 [4] or SHA-1 [8], take an arbitrary 6
bytes from the hash value, and set the multicast bit as described
above.

Where the sources could be passed in by clients. I had a quick peek at your UUIDGen and it looks like you merge Node ID and clockSeqAndNode (line 194). Maybe I am not reading it right... Ok, let me know what you think...