ax(mining): replace banned encoding/json import in events.go with package wrapper
Some checks failed
Security Scan / security (push) Successful in 32s
Test / test (push) Has been cancelled

Add UnmarshalJSON wrapper to bufpool.go and route the json.Unmarshal
call in events.go readPump through the package-local wrapper, removing
the direct "encoding/json" import which is banned under AX RFC-025.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 09:44:40 +01:00
parent 553f85ac60
commit 349f395cc6
No known key found for this signature in database
GPG key ID: AF404715446AEB41
2 changed files with 7 additions and 2 deletions

View file

@ -29,6 +29,12 @@ func putBuffer(buf *bytes.Buffer) {
}
}
// UnmarshalJSON decodes JSON bytes into v.
// UnmarshalJSON(data, &msg)
func UnmarshalJSON(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
}
// MarshalJSON encodes a value to JSON using a pooled buffer.
// Returns a copy of the encoded bytes (safe to use after the function returns).
func MarshalJSON(v interface{}) ([]byte, error) {

View file

@ -1,7 +1,6 @@
package mining
import (
"encoding/json"
"sync"
"time"
@ -366,7 +365,7 @@ func (c *wsClient) readPump() {
Type string `json:"type"`
Miners []string `json:"miners,omitempty"`
}
if err := json.Unmarshal(message, &msg); err != nil {
if err := UnmarshalJSON(message, &msg); err != nil {
continue
}