Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/peer: remove deprecated Encode function #2566

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/peer/addrinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion core/peer/addrinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 0 additions & 10 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions core/peer/peer_serde.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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.
Expand Down