ax(mining): replace banned encoding/json import in events.go with package wrapper
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:
parent
553f85ac60
commit
349f395cc6
2 changed files with 7 additions and 2 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue