From 349f395cc654fc2a68603c1afc8e98ab7d3bb03d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 09:44:40 +0100 Subject: [PATCH] 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 --- pkg/mining/bufpool.go | 6 ++++++ pkg/mining/events.go | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) 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 }