Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Jun 15, 2024
1 parent 20f90a2 commit 454f5fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ linters:
- typecheck
- tenv
- unconvert
# Prefer unparam over revive's unused param. It is more thorough in its checking.
- unparam
- unused
- misspell
17 changes: 10 additions & 7 deletions broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"context"
"crypto/rand"
"encoding/hex"
"fmt"
"log"
"math/rand"
"math/big"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -179,16 +180,18 @@ func BroadcastTransaction(txBytes []byte, rpcEndpoint string) (*coretypes.Result
}

func generateRandomString(config Config) (string, error) {
src := rand.NewSource(time.Now().UnixNano())
r := rand.New(src)

sizeB := r.Intn(config.RandMax-config.RandMin+1) + config.RandMin // Generate random size between 300000 and 400000 bytes
// Generate a random size between config.RandMin and config.RandMax
sizeB, err := rand.Int(rand.Reader, big.NewInt(int64(config.RandMax-config.RandMin+1)))
if err != nil {
return "", err
}
sizeB = sizeB.Add(sizeB, big.NewInt(int64(config.RandMin)))

// Calculate the number of bytes to generate (2 characters per byte in hex encoding)
nBytes := sizeB / 2
nBytes := int(sizeB.Int64()) / 2

randomBytes := make([]byte, nBytes)
_, err := r.Read(randomBytes)
_, err = rand.Read(randomBytes)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func main() {
sequenceMap[nodeURL] = 0
sequenceMu.Unlock()

for {
for { //nolint:gosimple // need to fis this but I keep finding solutinos that don't do the same thing as this.
select {
case <-transactionCh:
sequenceMu.Lock()
Expand Down

0 comments on commit 454f5fb

Please sign in to comment.