Skip to content

Commit c9ee644

Browse files
authored
Merge pull request #7984 from ipfs/feat/reimport-InitializeKeyspace-from-namesys
Feat: Re-import InitializeKeyspace code from go-namesys
2 parents 3c81d44 + 5ff3dd8 commit c9ee644

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

cmd/ipfs/init.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515
core "github.com/ipfs/go-ipfs/core"
1616
"github.com/ipfs/go-ipfs/core/commands"
1717
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
18-
namesys "github.com/ipfs/go-namesys"
18+
path "github.com/ipfs/go-path"
19+
unixfs "github.com/ipfs/go-unixfs"
1920

2021
cmds "github.com/ipfs/go-ipfs-cmds"
2122
config "github.com/ipfs/go-ipfs-config"
@@ -245,5 +246,19 @@ func initializeIpnsKeyspace(repoRoot string) error {
245246
}
246247
defer nd.Close()
247248

248-
return namesys.InitializeKeyspace(ctx, nd.Namesys, nd.Pinning, nd.PrivateKey)
249+
emptyDir := unixfs.EmptyDirNode()
250+
251+
// pin recursively because this might already be pinned
252+
// and doing a direct pin would throw an error in that case
253+
err = nd.Pinning.Pin(ctx, emptyDir, true)
254+
if err != nil {
255+
return err
256+
}
257+
258+
err = nd.Pinning.Flush(ctx)
259+
if err != nil {
260+
return err
261+
}
262+
263+
return nd.Namesys.Publish(ctx, nd.PrivateKey, path.FromCid(emptyDir.Cid()))
249264
}

0 commit comments

Comments
 (0)