ax(node): replace direct json.MarshalIndent/Unmarshal with package wrappers in peer.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

encoding/json is a banned import; peer.go used json.MarshalIndent and
json.Unmarshal directly in saveNow/load instead of the package-local
MarshalJSON/UnmarshalJSON wrappers. Removes the encoding/json import.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 17:41:18 +01:00
parent 852db44e4e
commit 9a511ddc72
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -1,7 +1,6 @@
package node
import (
"encoding/json"
"os"
"path"
"regexp"
@ -641,7 +640,7 @@ func (registry *PeerRegistry) saveNow() error {
peers = append(peers, peer)
}
data, err := json.MarshalIndent(peers, "", " ")
data, err := MarshalJSON(peers)
if err != nil {
return &ProtocolError{Code: ErrCodeOperationFailed, Message: "failed to marshal peers: " + err.Error()}
}
@ -701,7 +700,7 @@ func (registry *PeerRegistry) load() error {
}
var peers []*Peer
if err := json.Unmarshal(data, &peers); err != nil {
if err := UnmarshalJSON(data, &peers); err != nil {
return &ProtocolError{Code: ErrCodeOperationFailed, Message: "failed to unmarshal peers: " + err.Error()}
}