Use account service in secureservice instead of config

This commit is contained in:
mcrakhman 2023-01-06 20:55:10 +01:00 committed by Mikhail Iudin
parent 257a4d8e13
commit 3ec34e84bc
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

View File

@ -5,7 +5,6 @@ import (
commonaccount "github.com/anytypeio/any-sync/accountservice" commonaccount "github.com/anytypeio/any-sync/accountservice"
"github.com/anytypeio/any-sync/app" "github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/app/logger" "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/crypto"
"github.com/libp2p/go-libp2p/core/sec" "github.com/libp2p/go-libp2p/core/sec"
libp2ptls "github.com/libp2p/go-libp2p/p2p/security/tls" 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) { func (s *secureService) Init(a *app.App) (err error) {
account := a.MustComponent("config").(commonaccount.ConfigGetter).GetAccount() account := a.MustComponent(commonaccount.CName).(commonaccount.Service)
pkb, err := keys.DecodeBytesFromString(account.PeerKey) peerKey, err := account.Account().PeerKey.Raw()
if err != nil { if err != nil {
return return
} }
if s.key, err = crypto.UnmarshalEd25519PrivateKey(pkb); err != nil { if s.key, err = crypto.UnmarshalEd25519PrivateKey(peerKey); err != nil {
return return
} }
log.Info("secure service init", zap.String("peerId", account.PeerId)) log.Info("secure service init", zap.String("peerId", account.Account().PeerId))
return nil return nil
} }