diff --git a/core/peer/addrinfo.go b/core/peer/addrinfo.go index fba4cfd0eb..8c046f9588 100644 --- a/core/peer/addrinfo.go +++ b/core/peer/addrinfo.go @@ -86,7 +86,7 @@ func AddrInfoFromP2pAddr(m ma.Multiaddr) (*AddrInfo, error) { // AddrInfoToP2pAddrs converts an AddrInfo to a list of Multiaddrs. func AddrInfoToP2pAddrs(pi *AddrInfo) ([]ma.Multiaddr, error) { - p2ppart, err := ma.NewComponent("p2p", Encode(pi.ID)) + p2ppart, err := ma.NewComponent("p2p", pi.ID.String()) if err != nil { return nil, err } diff --git a/core/peer/addrinfo_test.go b/core/peer/addrinfo_test.go index 9f18a8b603..827b7f7327 100644 --- a/core/peer/addrinfo_test.go +++ b/core/peer/addrinfo_test.go @@ -19,7 +19,7 @@ func init() { if err != nil { panic(err) } - maddrPeer = ma.StringCast("/p2p/" + Encode(testID)) + maddrPeer = ma.StringCast("/p2p/" + testID.String()) maddrTpt = ma.StringCast("/ip4/127.0.0.1/tcp/1234") maddrFull = maddrTpt.Encapsulate(maddrPeer) } diff --git a/core/peer/peer.go b/core/peer/peer.go index f7f649f24d..ee08dd9f14 100644 --- a/core/peer/peer.go +++ b/core/peer/peer.go @@ -145,16 +145,6 @@ func Decode(s string) (ID, error) { return FromCid(c) } -// Encode encodes a peer ID as a string. -// -// At the moment, it base58 encodes the peer ID but, in the future, it will -// switch to encoding it as a CID by default. -// -// Deprecated: use id.String instead. -func Encode(id ID) string { - return id.String() -} - // FromCid converts a CID to a peer ID, if possible. func FromCid(c cid.Cid) (ID, error) { code := mc.Code(c.Type()) diff --git a/core/peer/peer_serde.go b/core/peer/peer_serde.go index 5fd1cd50c9..3e2f71793e 100644 --- a/core/peer/peer_serde.go +++ b/core/peer/peer_serde.go @@ -45,7 +45,7 @@ func (id ID) Size() int { } func (id ID) MarshalJSON() ([]byte, error) { - return json.Marshal(Encode(id)) + return json.Marshal(id.String()) } func (id *ID) UnmarshalJSON(data []byte) (err error) { @@ -59,7 +59,7 @@ func (id *ID) UnmarshalJSON(data []byte) (err error) { // MarshalText returns the text encoding of the ID. func (id ID) MarshalText() ([]byte, error) { - return []byte(Encode(id)), nil + return []byte(id.String()), nil } // UnmarshalText restores the ID from its text encoding.