diff --git a/pkg/mining/bufpool.go b/pkg/mining/bufpool.go index a0fab2c..1f98665 100644 --- a/pkg/mining/bufpool.go +++ b/pkg/mining/bufpool.go @@ -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) { diff --git a/pkg/mining/events.go b/pkg/mining/events.go index 11423ff..5d316af 100644 --- a/pkg/mining/events.go +++ b/pkg/mining/events.go @@ -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 }