Skip to content

Commit fc4abef

Browse files
committed
address review commnets
1 parent 5309095 commit fc4abef

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

rpc/ws/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func getUint64(data []byte, keys ...string) (val uint64, err error) {
174174
case jsonparser.Number, jsonparser.String:
175175
return strconv.ParseUint(string(v), 10, 64)
176176
default:
177-
return 0, fmt.Errorf("value is not a number/string: %s", string(v))
177+
return 0, fmt.Errorf("value is not a number/string: type=%d data=%s", t, string(v))
178178
}
179179
}
180180

rpc/ws/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package ws
2020
import (
2121
stdjson "encoding/json"
2222
"fmt"
23-
"math/rand"
23+
rand "math/rand/v2"
2424
"net/http"
2525
"time"
2626
)
@@ -32,17 +32,17 @@ type request struct {
3232
ID uint64 `json:"id"`
3333
}
3434

35-
const maxJSONRPCSafeInteger = uint64(1<<53 - 1)
35+
const maxJSONSafeInteger = uint64(1<<53 - 1)
3636

3737
func newRequest(params []any, method string, configuration map[string]any, shortID bool) *request {
3838
if params != nil && configuration != nil {
3939
params = append(params, configuration)
4040
}
4141
var ID uint64
4242
if !shortID {
43-
ID = uint64(rand.Int63n(int64(maxJSONRPCSafeInteger + 1)))
43+
ID = rand.Uint64N(maxJSONSafeInteger + 1)
4444
} else {
45-
ID = uint64(rand.Int31())
45+
ID = uint64(rand.Uint32N(1 << 31))
4646
}
4747
return &request{
4848
Version: "2.0",

rpc/ws/types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func TestNewRequest_IDWithinJSONSafeInteger(t *testing.T) {
1111
for range 2_000 {
1212
req := newRequest(nil, "slotSubscribe", nil, false)
13-
require.LessOrEqual(t, req.ID, maxJSONRPCSafeInteger)
13+
require.LessOrEqual(t, req.ID, maxJSONSafeInteger)
1414
}
1515
}
1616

0 commit comments

Comments
 (0)