From b4c105b5bd85a7ab343abeb85e335f48df3dac68 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 22 Jul 2021 15:36:32 -0700 Subject: [PATCH] fix: remove some deprecated calls --- core/commands/keyencode/keyencode.go | 3 +-- core/coreapi/test/api_test.go | 6 +++--- core/corehttp/logs.go | 2 +- core/node/builder.go | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/commands/keyencode/keyencode.go b/core/commands/keyencode/keyencode.go index 1db095d6d83..bdffac6ada3 100644 --- a/core/commands/keyencode/keyencode.go +++ b/core/commands/keyencode/keyencode.go @@ -29,8 +29,7 @@ func KeyEncoderFromString(formatLabel string) (KeyEncoder, error) { func (enc KeyEncoder) FormatID(id peer.ID) string { if enc.baseEnc == nil { - //nolint deprecated - return peer.IDB58Encode(id) + return peer.Encode(id) } if s, err := peer.ToCid(id).StringOfBase(enc.baseEnc.Encoding()); err != nil { panic(err) diff --git a/core/coreapi/test/api_test.go b/core/coreapi/test/api_test.go index e5ccb62dd6f..54f3b48ca43 100644 --- a/core/coreapi/test/api_test.go +++ b/core/coreapi/test/api_test.go @@ -22,7 +22,7 @@ import ( "github.com/ipfs/go-ipfs-config" coreiface "github.com/ipfs/interface-go-ipfs-core" "github.com/ipfs/interface-go-ipfs-core/tests" - ci "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/crypto" peer "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p/p2p/net/mock" ) @@ -40,7 +40,7 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) for i := 0; i < n; i++ { var ident config.Identity if fullIdentity { - sk, pk, err := ci.GenerateKeyPair(ci.RSA, 2048) + sk, pk, err := crypto.GenerateKeyPair(crypto.RSA, 2048) if err != nil { return nil, err } @@ -50,7 +50,7 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) return nil, err } - kbytes, err := sk.Bytes() + kbytes, err := crypto.MarshalPrivateKey(sk) if err != nil { return nil, err } diff --git a/core/corehttp/logs.go b/core/corehttp/logs.go index 99e8fa8853b..0d9cd1d7644 100644 --- a/core/corehttp/logs.go +++ b/core/corehttp/logs.go @@ -50,7 +50,7 @@ func LogOption() ServeOption { w.WriteHeader(200) wnf, errs := newWriteErrNotifier(w) lwriter.WriterGroup.AddWriter(wnf) - log.Event(n.Context(), "log API client connected") //nolint deprecated + log.Info("log API client connected") <-errs }) return mux, nil diff --git a/core/node/builder.go b/core/node/builder.go index 22ab500e150..803caf51885 100644 --- a/core/node/builder.go +++ b/core/node/builder.go @@ -15,7 +15,7 @@ import ( ds "github.com/ipfs/go-datastore" dsync "github.com/ipfs/go-datastore/sync" cfg "github.com/ipfs/go-ipfs-config" - ci "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/crypto" peer "github.com/libp2p/go-libp2p-core/peer" ) @@ -124,7 +124,7 @@ func (cfg *BuildCfg) options(ctx context.Context) (fx.Option, *cfg.Config) { func defaultRepo(dstore repo.Datastore) (repo.Repo, error) { c := cfg.Config{} - priv, pub, err := ci.GenerateKeyPairWithReader(ci.RSA, 2048, rand.Reader) + priv, pub, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, rand.Reader) if err != nil { return nil, err } @@ -134,7 +134,7 @@ func defaultRepo(dstore repo.Datastore) (repo.Repo, error) { return nil, err } - privkeyb, err := priv.Bytes() + privkeyb, err := crypto.MarshalPrivateKey(priv) if err != nil { return nil, err }