Skip to content

Commit

Permalink
Send rand() once in DB layer
Browse files Browse the repository at this point in the history
  • Loading branch information
otoolep committed Jan 12, 2022
1 parent 6cc2e37 commit ebb2ff3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions db/db.go
Expand Up @@ -39,6 +39,7 @@ var DBVersion string
var stats *expvar.Map

func init() {
rand.Seed(time.Now().UnixNano())
DBVersion, _, _ = sqlite3.Version()
stats = expvar.NewMap("db")
stats.Add(numExecutions, 0)
Expand All @@ -47,7 +48,6 @@ func init() {
stats.Add(numQueryErrors, 0)
stats.Add(numETx, 0)
stats.Add(numQTx, 0)

}

// DB is the SQL database.
Expand Down Expand Up @@ -961,7 +961,6 @@ func randomString() string {
var output strings.Builder
chars := "abcdedfghijklmnopqrstABCDEFGHIJKLMNOP"

rand.Seed(time.Now().UnixNano())
for i := 0; i < 20; i++ {
random := rand.Intn(len(chars))
randomChar := chars[random]
Expand Down

0 comments on commit ebb2ff3

Please sign in to comment.