Skip to content

Instantly share code, notes, and snippets.

@pedrouid
Last active February 13, 2023 15:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pedrouid/eb89f3ac161fe61f5be1fc2d1f6625b6 to your computer and use it in GitHub Desktop.
Increase rpc_id entropy
// 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