-
Notifications
You must be signed in to change notification settings - Fork 66
Rework key generator algorithm #153
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
Conversation
@aliams can you review? |
From my perspective, it looks good, but I have a few concerns:
should be something like the following (unless the former behavior is being changed):
(Note that it is safe to use this language since you set
...an implementation note should perhaps be added to mention that if |
Thanks @brettz9 ! Yes, I missed both the floor() step and incrementing. :( I've hopefully corrected the steps, and made a note about where the limit comes from, although I didn't go into "what if..." detail. Re: altering the maximum: We already have tests around the boundary condition and that the generator may produce 9007199254740992 so I don't think we want to reduce that. In a pure JS implementation I scraped together to sanity check my logic, I used e.g.: this.current += 1;
if (this.current === key)
this.current = Infinity; and if (value >= this.current) {
this.current = value + 1;
if (this.current === value)
this.current = Infinity;
} An implementation using |
|
As had I. :) |
9764fdc
to
7f5c34d
Compare
7f5c34d
to
4ce1255
Compare
I see one other issue... The current number definition states the following:
However the steps to "generate a key" and "possibly update the key generator" both allow for a current number to be set to a number one higher than 9007199254740992 as does the following:
I believe the current number definition ought to be reworded, e.g., like this:
|
Perhaps this text:
ought to be clarified as well to make clear that reaching above that value for the first time won't return the exception:
|
Nice, thanks. I'll incorporate those suggestions. |
4ce1255
to
2350fd3
Compare
Fix update steps
Tests coming in web-platform-tests/wpt#5065 |
2350fd3
to
cf49cf8
Compare
Address the spec gaps pointed out in #147
This pins the key generator to the maximum value (2^53). The logic around incrementing/updating the generator is made algorithmic rather than being duplicated between the object store storage operation steps and the prose definition of the key generator.