Skip to content

Commit

Permalink
stop using go-libp2p deprecated peer.ID.Pretty
Browse files Browse the repository at this point in the history
Signed-off-by: Icarus9913 <icaruswu66@qq.com>
  • Loading branch information
Icarus9913 committed Sep 12, 2023
1 parent 0eeb1f5 commit 92da467
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ docs/examples/go-ipfs-as-a-library/example-folder/Qm*
/parts
/stage
/prime

# IdeaIDE
.idea
2 changes: 1 addition & 1 deletion config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
if err != nil {
return ident, err
}
ident.PeerID = id.Pretty()
ident.PeerID = id.String()
fmt.Fprintf(out, "peer identity: %s\n", ident.PeerID)
return ident, nil
}
2 changes: 1 addition & 1 deletion core/commands/name/ipns.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Resolve the value of a dnslink:
if err != nil {
return err
}
name = self.ID().Pretty()
name = self.ID().String()
} else {
name = req.Arguments[0]
}
Expand Down
2 changes: 1 addition & 1 deletion core/commands/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ TOPIC AND DATA ENCODING
encoder, _ := mbase.EncoderByName("base64url")
psm := pubsubMessage{
Data: encoder.Encode(msg.Data()),
From: msg.From().Pretty(),
From: msg.From().String(),
Seqno: encoder.Encode(msg.Seq()),
}
for _, topic := range msg.Topics() {
Expand Down
8 changes: 4 additions & 4 deletions core/commands/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ var swarmPeersCmd = &cmds.Command{
for _, c := range conns {
ci := connInfo{
Addr: c.Address().String(),
Peer: c.ID().Pretty(),
Peer: c.ID().String(),
}

if verbose || direction {
Expand Down Expand Up @@ -536,7 +536,7 @@ var swarmAddrsCmd = &cmds.Command{

out := make(map[string][]string)
for p, paddrs := range addrs {
s := p.Pretty()
s := p.String()
for _, a := range paddrs {
out[s] = append(out[s], a.String())
}
Expand Down Expand Up @@ -680,7 +680,7 @@ ipfs swarm connect /ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N

output := make([]string, len(pis))
for i, pi := range pis {
output[i] = "connect " + pi.ID.Pretty()
output[i] = "connect " + pi.ID.String()

err := api.Swarm().Connect(req.Context, pi)
if err != nil {
Expand Down Expand Up @@ -745,7 +745,7 @@ it will reconnect.
// a good backwards compat solution. Right now, I'm just
// preserving the current behavior.
for _, addr := range maddrs {
msg := "disconnect " + ainfo.ID.Pretty()
msg := "disconnect " + ainfo.ID.String()
if err := api.Swarm().Disconnect(req.Context, addr); err != nil {
msg += " failure: " + err.Error()
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/coreapi/test/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdentity
}

ident = config.Identity{
PeerID: id.Pretty(),
PeerID: id.String(),
PrivKey: base64.StdEncoding.EncodeToString(kbytes),
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func defaultRepo(dstore repo.Datastore) (repo.Repo, error) {

c.Bootstrap = cfg.DefaultBootstrapAddresses
c.Addresses.Swarm = []string{"/ip4/0.0.0.0/tcp/4001", "/ip4/0.0.0.0/udp/4001/quic-v1"}
c.Identity.PeerID = pid.Pretty()
c.Identity.PeerID = pid.String()
c.Identity.PrivKey = base64.StdEncoding.EncodeToString(privkeyb)

return &repo.Mock{
Expand Down
2 changes: 1 addition & 1 deletion core/node/libp2p/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func LimitConfigsToInfo(stats LimitsConfigAndUsage) ResourceInfos {

for i, p := range stats.Peers {
result = append(result, resourceLimitsAndUsageToResourceInfo(
config.ResourceMgrPeerScopePrefix+i.Pretty(),
config.ResourceMgrPeerScopePrefix+i.String(),
p,
)...)
}
Expand Down
4 changes: 2 additions & 2 deletions fuse/ipns/ipns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestIpnsLocalLink(t *testing.T) {
t.Fatal(err)
}

if linksto != nd.Identity.Pretty() {
if linksto != nd.Identity.String() {
t.Fatal("Link invalid")
}
}
Expand All @@ -176,7 +176,7 @@ func TestIpnsBasicIO(t *testing.T) {
t.Fatal("Incorrect Read!")
}

fname2 := mnt.Dir + "/" + nd.Identity.Pretty() + "/testfile"
fname2 := mnt.Dir + "/" + nd.Identity.String() + "/testfile"
rbuf, err = os.ReadFile(fname2)
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion fuse/ipns/ipns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (r *Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
listing := make([]fuse.Dirent, 0, len(r.Keys)*2)
for alias, k := range r.Keys {
ent := fuse.Dirent{
Name: k.ID().Pretty(),
Name: k.ID().String(),
Type: fuse.DT_Dir,
}
link := fuse.Dirent{
Expand Down
2 changes: 1 addition & 1 deletion p2p/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (l *localListener) setupStream(local manet.Conn) {
remote, err := l.dial(l.ctx)
if err != nil {
local.Close()
log.Warnf("failed to dial to remote %s/%s", l.peer.Pretty(), l.proto)
log.Warnf("failed to dial to remote %s/%s", l.peer.String(), l.proto)
return
}

Expand Down

0 comments on commit 92da467

Please sign in to comment.