Snowflake limit

What's this limitation 4095 in @sapphire/snowflake?
5 Replies
Newbie
NewbieOP2y ago
GitHub
utilities/Snowflake.ts at main · sapphiredev/utilities
Common JavaScript utilities for Sapphire Projects. Contribute to sapphiredev/utilities development by creating an account on GitHub.
Favna
Favna2y ago
@kyra 🩵🩷🤍🩷🩵 ThisPoint
kyra
kyra2y ago
If you check the layout the snowflake has, you can see how many bits each part has:
64 22 17 12 0
000000111011000111100001101001000101000000 00001 00000 000000000000
number of ms since epoch worker pid increment
64 22 17 12 0
000000111011000111100001101001000101000000 00001 00000 000000000000
number of ms since epoch worker pid increment
As you can see, the increment can be one number between 0 (0b000000000000) and 4095 (0b111111111111). If you pass an increment, you're acknowledging you know what you're doing, as this is an advanced option. As for what the behaviour is when we surpass the range [0, 4095], is completely specific to the implementation, there isn't really a single implementation that's intuitive for everyone. However, now that you point it out, we should likely just mask it into the valid range, otherwise negative values get into the other fields, I have to fix that sweats And also the cycle should happen at 4096 (>4095 or >=4096), we're accidentally 1 possible increment off, I'll fix that ASAP, will update this message with a link to the PR https://github.com/sapphiredev/utilities/pull/596. At the end, I encountered a lot more bugs. sweats
Favna
Favna2y ago
Fixed in the latest release of the library
Newbie
NewbieOP2y ago
I reply a little bit late, but thanks! ❤️
Want results from more Discord servers?
Add your server