ax(node): replace direct json.MarshalIndent/Unmarshal with package wrappers in peer.go
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:
parent
852db44e4e
commit
9a511ddc72
1 changed files with 2 additions and 3 deletions
|
|
@ -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()}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue