diff --git a/node/builder.go b/node/builder.go index 4a81df2d8..0ba8e246c 100644 --- a/node/builder.go +++ b/node/builder.go @@ -205,6 +205,10 @@ func Repo(r repo.Repo) Option { if err != nil { return Error(err) } + pk, err := lr.Libp2pIdentity() + if err != nil { + return Error(err) + } return Options( Config(cfg), @@ -212,6 +216,10 @@ func Repo(r repo.Repo) Option { Override(new(datastore.Batching), modules.Datastore), Override(new(blockstore.Blockstore), modules.Blockstore), + + Override(new(ci.PrivKey), pk), + Override(new(ci.PubKey), ci.PrivKey.GetPublic), + Override(new(peer.ID), peer.IDFromPublicKey), ) } diff --git a/node/repo/fsrepo.go b/node/repo/fsrepo.go index 0aa66fcbf..27d9d24a4 100644 --- a/node/repo/fsrepo.go +++ b/node/repo/fsrepo.go @@ -45,7 +45,7 @@ var _ Repo = &FsRepo{} func NewFS(path string) (*FsRepo, error) { path, err := homedir.Expand(path) if err != nil { - return &FsRepo{}, err + return nil, err } return &FsRepo{ @@ -175,6 +175,13 @@ func (fsr *fsLockedRepo) Libp2pIdentity() (crypto.PrivKey, error) { if err != nil { return nil, xerrors.Errorf("could not write private key: %w", err) } + } else if err != nil { + return nil, err + } + + stat, err = os.Stat(kpath) + if err != nil { + return nil, err } if stat.Mode()&0066 != 0 {