mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-05 16:28:06 +08:00
InitializeKeyspace doesnt care about fuse
This commit is contained in:
parent
66f1035d93
commit
293234ae63
37
fuse/ipns/common.go
Normal file
37
fuse/ipns/common.go
Normal file
@ -0,0 +1,37 @@
|
||||
package ipns
|
||||
|
||||
import (
|
||||
"github.com/jbenet/go-ipfs/core"
|
||||
mdag "github.com/jbenet/go-ipfs/merkledag"
|
||||
nsys "github.com/jbenet/go-ipfs/namesys"
|
||||
ci "github.com/jbenet/go-ipfs/p2p/crypto"
|
||||
ft "github.com/jbenet/go-ipfs/unixfs"
|
||||
)
|
||||
|
||||
// InitializeKeyspace sets the ipns record for the given key to
|
||||
// point to an empty directory.
|
||||
func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error {
|
||||
emptyDir := &mdag.Node{Data: ft.FolderPBData()}
|
||||
nodek, err := n.DAG.Add(emptyDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = n.Pinning.Pin(emptyDir, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = n.Pinning.Flush()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pub := nsys.NewRoutingPublisher(n.Routing)
|
||||
err = pub.Publish(n.Context(), key, nodek)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -20,7 +20,6 @@ import (
|
||||
core "github.com/jbenet/go-ipfs/core"
|
||||
chunk "github.com/jbenet/go-ipfs/importer/chunk"
|
||||
mdag "github.com/jbenet/go-ipfs/merkledag"
|
||||
nsys "github.com/jbenet/go-ipfs/namesys"
|
||||
ci "github.com/jbenet/go-ipfs/p2p/crypto"
|
||||
path "github.com/jbenet/go-ipfs/path"
|
||||
ft "github.com/jbenet/go-ipfs/unixfs"
|
||||
@ -39,34 +38,6 @@ var (
|
||||
longRepublishTimeout = time.Millisecond * 500
|
||||
)
|
||||
|
||||
// InitializeKeyspace sets the ipns record for the given key to
|
||||
// point to an empty directory.
|
||||
func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error {
|
||||
emptyDir := &mdag.Node{Data: ft.FolderPBData()}
|
||||
nodek, err := n.DAG.Add(emptyDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = n.Pinning.Pin(emptyDir, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = n.Pinning.Flush()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pub := nsys.NewRoutingPublisher(n.Routing)
|
||||
err = pub.Publish(n.Context(), key, nodek)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// FileSystem is the readwrite IPNS Fuse Filesystem.
|
||||
type FileSystem struct {
|
||||
Ipfs *core.IpfsNode
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
// +build nofuse
|
||||
|
||||
package ipns
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/jbenet/go-ipfs/core"
|
||||
ci "github.com/jbenet/go-ipfs/p2p/crypto"
|
||||
)
|
||||
|
||||
// InitializeKeyspace sets the ipns record for the given key to
|
||||
// point to an empty directory.
|
||||
func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error {
|
||||
// emptyDir := &mdag.Node{Data: ft.FolderPBData()}
|
||||
// nodek, err := n.DAG.Add(emptyDir)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// err = n.Pinning.Pin(emptyDir, false)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// err = n.Pinning.Flush()
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// pub := nsys.NewRoutingPublisher(n.Routing)
|
||||
// err = pub.Publish(n.Context(), key, nodek)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
return errors.New("how is this fuse related?")
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user