Skip to content

Commit

Permalink
Merge pull request #7984 from ipfs/feat/reimport-InitializeKeyspace-f…
Browse files Browse the repository at this point in the history
…rom-namesys

Feat: Re-import InitializeKeyspace code from go-namesys
  • Loading branch information
Stebalien authored Mar 22, 2021
2 parents 3c81d44 + 5ff3dd8 commit c9ee644
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (
core "github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/core/commands"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
namesys "github.com/ipfs/go-namesys"
path "github.com/ipfs/go-path"
unixfs "github.com/ipfs/go-unixfs"

cmds "github.com/ipfs/go-ipfs-cmds"
config "github.com/ipfs/go-ipfs-config"
Expand Down Expand Up @@ -245,5 +246,19 @@ func initializeIpnsKeyspace(repoRoot string) error {
}
defer nd.Close()

return namesys.InitializeKeyspace(ctx, nd.Namesys, nd.Pinning, nd.PrivateKey)
emptyDir := unixfs.EmptyDirNode()

// pin recursively because this might already be pinned
// and doing a direct pin would throw an error in that case
err = nd.Pinning.Pin(ctx, emptyDir, true)
if err != nil {
return err
}

err = nd.Pinning.Flush(ctx)
if err != nil {
return err
}

return nd.Namesys.Publish(ctx, nd.PrivateKey, path.FromCid(emptyDir.Cid()))
}

0 comments on commit c9ee644

Please sign in to comment.