-
-
Notifications
You must be signed in to change notification settings - Fork 145
Thread safe ID generation #218
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
| ids.TryAdd(header.Id, 0); | ||
| }); | ||
|
|
||
| Assert.True(ids.Count > 950, $"Only {ids.Count} of 1000 ids are unique!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the change the number of collisions is significantly higher.
|
I was actually adding a fix for this in my open PR, too: Now I'm wondering, why did you remove the version with RandomNumberGenerator in favor of a lock? |
|
In #207 the two implementation paths have different characteristics: In my understanding client txid-s don't have to be cryptographically secure random numbers, so no need to use |
|
gotcha.
yup that is also my understanding. |
Fix #209
and use cryptographically strong random numbersEdit: removed the latter, the vulnerability doesn't apply to clients..