Skip to content

Commit

Permalink
No error if PrivateKey is already loaded
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Andres Buritica <andres@thelinuxkid.com>
  • Loading branch information
thelinuxkid committed Jan 17, 2016
1 parent cef5e57 commit fab42c9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,12 @@ func (n *IpfsNode) loadID() error {
}

func (n *IpfsNode) LoadPrivateKey() error {
if n.Identity == "" || n.Peerstore == nil {
return errors.New("loaded private key out of order.")
if n.PrivateKey != nil {
return nil
}

if n.PrivateKey != nil {
return errors.New("private key already loaded")
if n.Identity == "" || n.Peerstore == nil {
return errors.New("loaded private key out of order.")
}

cfg, err := n.Repo.Config()
Expand Down Expand Up @@ -510,10 +510,9 @@ func (n *IpfsNode) loadFilesRoot() error {
// uses it to instantiate a routing system in offline mode.
// This is primarily used for offline ipns modifications.
func (n *IpfsNode) SetupOfflineRouting() error {
if n.PrivateKey == nil {
if err := n.LoadPrivateKey(); err != nil {
return err
}
err := n.LoadPrivateKey()
if err != nil {
return err
}

n.Routing = offroute.NewOfflineRouter(n.Repo.Datastore(), n.PrivateKey)
Expand Down

0 comments on commit fab42c9

Please sign in to comment.