Skip to content

Commit

Permalink
Merge pull request #11263 from Icarus9913/libp2p/remove-deprecated-me…
Browse files Browse the repository at this point in the history
…thod

fix: deps: stop using go-libp2p deprecated peer.ID.Pretty
  • Loading branch information
magik6k authored Sep 22, 2023
2 parents c11a5bc + 2a8ea95 commit 9999050
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion chain/exchange/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (c *client) sendRequestToPeer(ctx context.Context, peer peer.ID, req *Reque
defer span.End()
if span.IsRecordingEvents() {
span.AddAttributes(
trace.StringAttribute("peer", peer.Pretty()),
trace.StringAttribute("peer", peer.String()),
)
}
defer func() {
Expand Down
4 changes: 2 additions & 2 deletions cli/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ var NetDisconnect = &cli.Command{
fmt.Println("failure")
return err
}
fmt.Printf("disconnect %s: ", pid.Pretty())
fmt.Printf("disconnect %s: ", pid)
err = api.NetDisconnect(ctx, pid)
if err != nil {
fmt.Println("failure")
Expand Down Expand Up @@ -312,7 +312,7 @@ var NetConnect = &cli.Command{
}

for _, pi := range pis {
fmt.Printf("connect %s: ", pi.ID.Pretty())
fmt.Printf("connect %s: ", pi.ID)
err := api.NetConnect(ctx, pi)
if err != nil {
fmt.Println("failure")
Expand Down
2 changes: 1 addition & 1 deletion itests/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (ts *apiSuite) testID(t *testing.T) {
if err != nil {
t.Fatal(err)
}
require.Regexp(t, "^12", id.Pretty())
require.Regexp(t, "^12", id.String())
}

func (ts *apiSuite) testConnectTwo(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions lib/consensus/raft/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (cc *Consensus) RedirectToLeader(method string, arg interface{}, ret interf
return false, nil
}

logger.Debugf("redirecting %s to leader: %s", method, leader.Pretty())
logger.Debugf("redirecting %s to leader: %s", method, leader)
finalErr = cc.RpcClient.CallContext(
ctx,
leader,
Expand Down Expand Up @@ -394,7 +394,7 @@ func (cc *Consensus) Commit(ctx context.Context, op *ConsensusOp) error {
func (cc *Consensus) AddPeer(ctx context.Context, pid peer.ID) error {
var finalErr error
for i := 0; i <= cc.config.CommitRetries; i++ {
logger.Debugf("attempt #%d: AddPeer %s", i, pid.Pretty())
logger.Debugf("attempt #%d: AddPeer %s", i, pid)
if finalErr != nil {
logger.Errorf("retrying to add peer. Attempt #%d failed: %s", i, finalErr)
}
Expand All @@ -408,7 +408,7 @@ func (cc *Consensus) AddPeer(ctx context.Context, pid peer.ID) error {
time.Sleep(cc.config.CommitRetryDelay)
continue
}
logger.Infof("peer added to Raft: %s", pid.Pretty())
logger.Infof("peer added to Raft: %s", pid)
break
}
return finalErr
Expand All @@ -419,7 +419,7 @@ func (cc *Consensus) AddPeer(ctx context.Context, pid peer.ID) error {
func (cc *Consensus) RmPeer(ctx context.Context, pid peer.ID) error {
var finalErr error
for i := 0; i <= cc.config.CommitRetries; i++ {
logger.Debugf("attempt #%d: RmPeer %s", i, pid.Pretty())
logger.Debugf("attempt #%d: RmPeer %s", i, pid)
if finalErr != nil {
logger.Errorf("retrying to remove peer. Attempt #%d failed: %s", i, finalErr)
}
Expand All @@ -433,7 +433,7 @@ func (cc *Consensus) RmPeer(ctx context.Context, pid peer.ID) error {
time.Sleep(cc.config.CommitRetryDelay)
continue
}
logger.Infof("peer removed from Raft: %s", pid.Pretty())
logger.Infof("peer removed from Raft: %s", pid)
break
}
return finalErr
Expand Down
2 changes: 1 addition & 1 deletion node/impl/net/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (a *NetAPI) NetStat(ctx context.Context, scope string) (result api.NetStat,
if len(stat.Peers) > 0 {
result.Peers = make(map[string]network.ScopeStat, len(stat.Peers))
for p, stat := range stat.Peers {
result.Peers[p.Pretty()] = stat
result.Peers[p.String()] = stat
}
}

Expand Down
2 changes: 1 addition & 1 deletion node/modules/lp2p/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Peerstore() (peerstore.Peerstore, error) {
func Host(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (RawHost, error) {
pkey := params.Peerstore.PrivKey(params.ID)
if pkey == nil {
return nil, fmt.Errorf("missing private key for node ID: %s", params.ID.Pretty())
return nil, fmt.Errorf("missing private key for node ID: %s", params.ID)
}

opts := []libp2p.Option{
Expand Down

0 comments on commit 9999050

Please sign in to comment.