1
0
mirror of https://github.com/libp2p/go-libp2p-peerstore.git synced 2025-03-24 13:10:06 +08:00

PeerInfo UnMarshal Error

This commit is contained in:
wzp 2018-11-08 10:12:34 +08:00
parent 545f62f160
commit e9ca112fea

View File

@ -70,14 +70,14 @@ 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,
}
}
func (pi *PeerInfo) MarshalJSON() ([]byte, error) {
func (pi PeerInfo) MarshalJSON() ([]byte, error) {
out := make(map[string]interface{})
out["ID"] = pi.ID.Pretty()
var addrs []string
@ -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 {