Skip to content

Commit

Permalink
Remove InitializeKeyspace function from publisher
Browse files Browse the repository at this point in the history
This is mostly go-ipfs specific and has been moved there.

See ipfs/kubo#7984


This commit was moved from ipfs/go-namesys@67510bf
  • Loading branch information
hsanjuan committed Mar 16, 2021
1 parent 99f7d76 commit eb3d7dd
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions namesys/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import (
proto "github.com/gogo/protobuf/proto"
ds "github.com/ipfs/go-datastore"
dsquery "github.com/ipfs/go-datastore/query"
pin "github.com/ipfs/go-ipfs-pinner"
ipns "github.com/ipfs/go-ipns"
pb "github.com/ipfs/go-ipns/pb"
path "github.com/ipfs/go-path"
ft "github.com/ipfs/go-unixfs"
ci "github.com/libp2p/go-libp2p-core/crypto"
peer "github.com/libp2p/go-libp2p-core/peer"
routing "github.com/libp2p/go-libp2p-core/routing"
Expand Down Expand Up @@ -294,27 +292,6 @@ func PublishEntry(ctx context.Context, r routing.ValueStore, ipnskey string, rec
return r.PutValue(ctx, ipnskey, data)
}

// InitializeKeyspace sets the ipns record for the given key to
// point to an empty directory.
// TODO: this doesnt feel like it belongs here
func InitializeKeyspace(ctx context.Context, pub Publisher, pins pin.Pinner, key ci.PrivKey) error {
emptyDir := ft.EmptyDirNode()

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

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

return pub.Publish(ctx, key, path.FromCid(emptyDir.Cid()))
}

// PkKeyForID returns the public key routing key for the given peer ID.
func PkKeyForID(id peer.ID) string {
return "/pk/" + string(id)
Expand Down

0 comments on commit eb3d7dd

Please sign in to comment.