From 3ec34e84bca1517ce70f107254b0360a488c6feb Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Fri, 6 Jan 2023 20:55:10 +0100 Subject: [PATCH] Use account service in secureservice instead of config --- net/secureservice/secureservice.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/net/secureservice/secureservice.go b/net/secureservice/secureservice.go index 814df847..d83d1c94 100644 --- a/net/secureservice/secureservice.go +++ b/net/secureservice/secureservice.go @@ -5,7 +5,6 @@ import ( commonaccount "github.com/anytypeio/any-sync/accountservice" "github.com/anytypeio/any-sync/app" "github.com/anytypeio/any-sync/app/logger" - "github.com/anytypeio/any-sync/util/keys" "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/sec" libp2ptls "github.com/libp2p/go-libp2p/p2p/security/tls" @@ -35,16 +34,16 @@ type secureService struct { } func (s *secureService) Init(a *app.App) (err error) { - account := a.MustComponent("config").(commonaccount.ConfigGetter).GetAccount() - pkb, err := keys.DecodeBytesFromString(account.PeerKey) + account := a.MustComponent(commonaccount.CName).(commonaccount.Service) + peerKey, err := account.Account().PeerKey.Raw() if err != nil { return } - if s.key, err = crypto.UnmarshalEd25519PrivateKey(pkb); err != nil { + if s.key, err = crypto.UnmarshalEd25519PrivateKey(peerKey); err != nil { return } - log.Info("secure service init", zap.String("peerId", account.PeerId)) + log.Info("secure service init", zap.String("peerId", account.Account().PeerId)) return nil }