InitializeKeyspace doesnt care about fuse

This commit is contained in:
Henry 2015-03-05 00:18:59 +01:00
parent 66f1035d93
commit 293234ae63
3 changed files with 37 additions and 67 deletions

37
fuse/ipns/common.go Normal file
View 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
}

View File

@ -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

View File

@ -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?")
}