Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
9c2ac6fb
Unverified
Commit
9c2ac6fb
authored
Jul 31, 2020
by
Felix Lange
Committed by
GitHub
Jul 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpc: remove silly use of ReadVarint in subscription ID generator (#21391)
Found by @protolambda
parent
a00dc509
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
subscription.go
rpc/subscription.go
+6
-3
No files found.
rpc/subscription.go
View file @
9c2ac6fb
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
rpc
package
rpc
import
(
import
(
"bufio"
"container/list"
"container/list"
"context"
"context"
crand
"crypto/rand"
crand
"crypto/rand"
...
@@ -51,10 +50,14 @@ func NewID() ID {
...
@@ -51,10 +50,14 @@ func NewID() ID {
// randomIDGenerator returns a function generates a random IDs.
// randomIDGenerator returns a function generates a random IDs.
func
randomIDGenerator
()
func
()
ID
{
func
randomIDGenerator
()
func
()
ID
{
seed
,
err
:=
binary
.
ReadVarint
(
bufio
.
NewReader
(
crand
.
Reader
))
var
buf
=
make
([]
byte
,
8
)
if
err
!=
nil
{
var
seed
int64
if
_
,
err
:=
crand
.
Read
(
buf
);
err
==
nil
{
seed
=
int64
(
binary
.
BigEndian
.
Uint64
(
buf
))
}
else
{
seed
=
int64
(
time
.
Now
()
.
Nanosecond
())
seed
=
int64
(
time
.
Now
()
.
Nanosecond
())
}
}
var
(
var
(
mu
sync
.
Mutex
mu
sync
.
Mutex
rng
=
rand
.
New
(
rand
.
NewSource
(
seed
))
rng
=
rand
.
New
(
rand
.
NewSource
(
seed
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment