Last active
February 13, 2023 15:02
-
-
Save pedrouid/eb89f3ac161fe61f5be1fc2d1f6625b6 to your computer and use it in GitHub Desktop.
Increase rpc_id entropy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Our RPC id's are expected to be the same "length" | |
// generating id's should use Unix epoch timestamp in miliseconds and append 3 random digits | |
// currently Kotlin SDK has at least 3 more digits than all other SDKs | |
// yet while Kotlin is the minority, it's preferable to increase integers than decrease them | |
// this way we can keep backwards-compatibility for Kotlin clients in older releases | |
// thus we could also increase entropy by also increasing other SDKs to 6 random digits | |
function payloadId() { | |
const date = Date.now() * Math.pow(10, 6); | |
const extra = Math.ceil(Math.random() * Math.pow(10, 6)); | |
return date + extra; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment