bug fix: UnmarshalJSON should take a pointer

This commit is contained in:
Eli Wang 2018-11-08 10:40:39 +08:00 committed by GitHub
parent e9ca112fea
commit ab8c6cbfd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,7 @@ func InfoToP2pAddrs(pi *PeerInfo) ([]ma.Multiaddr, error) {
return addrs, nil
}
func (pi PeerInfo) Loggable() map[string]interface{} {
func (pi *PeerInfo) Loggable() map[string]interface{} {
return map[string]interface{}{
"peerID": pi.ID.Pretty(),
"addrs": pi.Addrs,
@ -88,7 +88,7 @@ func (pi PeerInfo) MarshalJSON() ([]byte, error) {
return json.Marshal(out)
}
func (pi PeerInfo) UnmarshalJSON(b []byte) error {
func (pi *PeerInfo) UnmarshalJSON(b []byte) error {
var data map[string]interface{}
err := json.Unmarshal(b, &data)
if err != nil {