Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Re-import InitializeKeyspace code from go-namesys #7984

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()))
}