Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
chore: mark exported types as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
guseggert committed May 11, 2023
1 parent 28f3e55 commit b08a89b
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 16 deletions.
1 change: 1 addition & 0 deletions file/unixfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func newUnixfsDir(ctx context.Context, dserv ipld.DAGService, nd *dag.ProtoNode)
}, nil
}

// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/file.NewUnixfsFile
func NewUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node) (files.Node, error) {
switch dn := nd.(type) {
case *dag.ProtoNode:
Expand Down
10 changes: 10 additions & 0 deletions hamt/hamt.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import (

const (
// HashMurmur3 is the multiformats identifier for Murmur3
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/hamt.HashMurmur3
HashMurmur3 uint64 = 0x22
)

Expand All @@ -53,6 +55,8 @@ func (ds *Shard) isValueNode() bool {
}

// A Shard represents the HAMT. It should be initialized with NewShard().
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/hamt.Shard
type Shard struct {
childer *childer

Expand Down Expand Up @@ -85,11 +89,15 @@ type Shard struct {
}

// NewShard creates a new, empty HAMT shard with the given size.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/hamt.NewShard
func NewShard(dserv ipld.DAGService, size int) (*Shard, error) {
return NewShardValue(dserv, size, "", nil)
}

// NewShardValue creates a new, empty HAMT shard with the given key, value and size.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/hamt.NewShardValue
func NewShardValue(dserv ipld.DAGService, size int, key string, value *ipld.Link) (*Shard, error) {
ds, err := makeShard(dserv, size, key, value)
if err != nil {
Expand Down Expand Up @@ -129,6 +137,8 @@ func makeShard(ds ipld.DAGService, size int, key string, val *ipld.Link) (*Shard
}

// NewHamtFromDag creates new a HAMT shard from the given DAG.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/hamt.NewHamtFromDag
func NewHamtFromDag(dserv ipld.DAGService, nd ipld.Node) (*Shard, error) {
pbnd, ok := nd.(*dag.ProtoNode)
if !ok {
Expand Down
1 change: 1 addition & 0 deletions hamt/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (hb *hashBits) next(i int) int {
}
}

// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/hamt.Logtwo
func Logtwo(v int) (int, error) {
if v <= 0 {
return 0, fmt.Errorf("hamt size should be a power of two")
Expand Down
2 changes: 2 additions & 0 deletions importer/balanced/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ import (
// +=========+ +=========+ + - - - - +
// | Chunk 1 | | Chunk 2 | | Chunk 3 |
// +=========+ +=========+ + - - - - +
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/balanced.Layout
func Layout(db *h.DagBuilderHelper) (ipld.Node, error) {
if db.Done() {
// No data, return just an empty node.
Expand Down
9 changes: 9 additions & 0 deletions importer/helpers/dagbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ import (
ipld "github.com/ipfs/go-ipld-format"
)

// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/helpers.ErrMissingFsRef
var ErrMissingFsRef = errors.New("missing file path or URL, can't create filestore reference")

// DagBuilderHelper wraps together a bunch of objects needed to
// efficiently create unixfs dag trees
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/helpers.DagBuilderHelper
type DagBuilderHelper struct {
dserv ipld.DAGService
spl chunker.Splitter
Expand All @@ -48,6 +51,8 @@ type DagBuilderHelper struct {

// DagBuilderParams wraps configuration options to create a DagBuilderHelper
// from a chunker.Splitter.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/helpers.DagBuilderParams
type DagBuilderParams struct {
// Maximum number of links per intermediate node
Maxlinks int
Expand Down Expand Up @@ -283,6 +288,8 @@ func (db *DagBuilderHelper) Maxlinks() int {
// many possible node state combinations.
//
// TODO: Revisit the name.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/helpers.FSNodeOverDag
type FSNodeOverDag struct {
dag *dag.ProtoNode
file *ft.FSNode
Expand All @@ -308,6 +315,8 @@ func (db *DagBuilderHelper) NewFSNFromDag(nd *dag.ProtoNode) (*FSNodeOverDag, er
}

// NewFSNFromDag reconstructs a FSNodeOverDag node from a given dag node
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/helpers.NewFSNFromDag
func NewFSNFromDag(nd *dag.ProtoNode) (*FSNodeOverDag, error) {
mb, err := ft.FSNodeFromBytes(nd.Data())
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions importer/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
)

// BlockSizeLimit specifies the maximum size an imported block can have.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/helpers.BlockSizeLimit
var BlockSizeLimit = 1048576 // 1 MB

// rough estimates on expected sizes
Expand All @@ -25,7 +27,11 @@ var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name + protobuf
// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
// = ( 8192 / 47 )
// = (approximately) 174
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/helpers.DefaultLinksPerBlock
var DefaultLinksPerBlock = roughLinkBlockSize / roughLinkSize

// ErrSizeLimitExceeded signals that a block is larger than BlockSizeLimit.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/helpers.ErrSizeLimitExceeded
var ErrSizeLimitExceeded = fmt.Errorf("object size limit exceeded")
4 changes: 4 additions & 0 deletions importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (

// BuildDagFromReader creates a DAG given a DAGService and a Splitter
// implementation (Splitters are io.Readers), using a Balanced layout.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer.BuildDagFromReader
func BuildDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, error) {
dbp := h.DagBuilderParams{
Dagserv: ds,
Expand All @@ -27,6 +29,8 @@ func BuildDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, er

// BuildTrickleDagFromReader creates a DAG given a DAGService and a Splitter
// implementation (Splitters are io.Readers), using a Trickle Layout.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer.BuildTrickleDagFromReader
func BuildTrickleDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, error) {
dbp := h.DagBuilderParams{
Dagserv: ds,
Expand Down
8 changes: 8 additions & 0 deletions importer/trickle/trickledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const depthRepeat = 4
// Layout builds a new DAG with the trickle format using the provided
// DagBuilderHelper. See the module's description for a more detailed
// explanation.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/trickle.Layout
func Layout(db *h.DagBuilderHelper) (ipld.Node, error) {
newRoot := db.NewFSNodeOverDag(ft.TFile)
root, _, err := fillTrickleRec(db, newRoot, -1)
Expand Down Expand Up @@ -87,6 +89,8 @@ func fillTrickleRec(db *h.DagBuilderHelper, node *h.FSNodeOverDag, maxDepth int)
}

// Append appends the data in `db` to the dag, using the Trickledag format
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/trickle.Append
func Append(ctx context.Context, basen ipld.Node, db *h.DagBuilderHelper) (out ipld.Node, errOut error) {
base, ok := basen.(*dag.ProtoNode)
if !ok {
Expand Down Expand Up @@ -276,6 +280,8 @@ func trickleDepthInfo(node *h.FSNodeOverDag, maxlinks int) (depth int, repeatNum
}

// VerifyParams is used by VerifyTrickleDagStructure
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/trickle.VerifyParams
type VerifyParams struct {
Getter ipld.NodeGetter
Direct int
Expand All @@ -286,6 +292,8 @@ type VerifyParams struct {

// VerifyTrickleDagStructure checks that the given dag matches exactly the trickle dag datastructure
// layout
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/importer/trickle.VerifyTrickleDagStructure
func VerifyTrickleDagStructure(nd ipld.Node, p VerifyParams) error {
return verifyTDagRec(nd, -1, p)
}
Expand Down
1 change: 1 addition & 0 deletions internal/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package internal

// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/internal.HAMTHashFunction
var HAMTHashFunction func(val []byte) []byte
14 changes: 12 additions & 2 deletions io/dagreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ import (

// Common errors
var (
ErrIsDir = errors.New("this dag node is a directory")
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrIsDir
ErrIsDir = errors.New("this dag node is a directory")
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrCantReadSymlinks
ErrCantReadSymlinks = errors.New("cannot currently read symlinks")
ErrUnkownNodeType = errors.New("unknown node type")
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrUnkownNodeType
ErrUnkownNodeType = errors.New("unknown node type")
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrSeekNotSupported
ErrSeekNotSupported = errors.New("file does not support seeking")
)

Expand All @@ -26,13 +30,17 @@ var (
// A DagReader provides read-only read and seek acess to a unixfs file.
// Different implementations of readers are used for the different
// types of unixfs/protobuf-encoded nodes.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.DagReader
type DagReader interface {
ReadSeekCloser
Size() uint64
CtxReadFull(context.Context, []byte) (int, error)
}

// A ReadSeekCloser implements interfaces to read, copy, seek and close.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ReadSeekCloser
type ReadSeekCloser interface {
io.Reader
io.Seeker
Expand All @@ -42,6 +50,8 @@ type ReadSeekCloser interface {

// NewDagReader creates a new reader object that reads the data represented by
// the given node, using the passed in DAGService for data retrieval.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.NewDagReader
func NewDagReader(ctx context.Context, n ipld.Node, serv ipld.NodeGetter) (DagReader, error) {
var size uint64

Expand Down
18 changes: 18 additions & 0 deletions io/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ var log = logging.Logger("unixfs")
// The size is not the *exact* block size of the encoded BasicDirectory but just
// the estimated size based byte length of links name and CID (BasicDirectory's
// ProtoNode doesn't use the Data field so this estimate is pretty accurate).
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.HAMTShardingSize
var HAMTShardingSize = int(256 * units.KiB)

// DefaultShardWidth is the default value used for hamt sharding width.
// Needs to be a power of two (shard entry size) and multiple of 8 (bitfield size).
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.DefaultShardWidth
var DefaultShardWidth = 256

// Directory defines a UnixFS directory. It is used for creating, reading and
Expand All @@ -37,6 +41,8 @@ var DefaultShardWidth = 256
// It just allows to perform explicit edits on a single directory, working with
// directory trees is out of its scope, they are managed by the MFS layer
// (which is the main consumer of this interface).
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.Directory
type Directory interface {

// SetCidBuilder sets the CID Builder of the root node.
Expand Down Expand Up @@ -88,6 +94,8 @@ func init() {

// BasicDirectory is the basic implementation of `Directory`. All the entries
// are stored in a single node.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.BasicDirectory
type BasicDirectory struct {
node *mdag.ProtoNode
dserv ipld.DAGService
Expand All @@ -102,6 +110,8 @@ type BasicDirectory struct {

// HAMTDirectory is the HAMT implementation of `Directory`.
// (See package `hamt` for more information.)
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.HAMTDirectory
type HAMTDirectory struct {
shard *hamt.Shard
dserv ipld.DAGService
Expand All @@ -128,15 +138,21 @@ func newBasicDirectoryFromNode(dserv ipld.DAGService, node *mdag.ProtoNode) *Bas

// NewDirectory returns a Directory implemented by DynamicDirectory
// containing a BasicDirectory that can be converted to a HAMTDirectory.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.NewDirectory
func NewDirectory(dserv ipld.DAGService) Directory {
return &DynamicDirectory{newEmptyBasicDirectory(dserv)}
}

// ErrNotADir implies that the given node was not a unixfs directory
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrNotADir
var ErrNotADir = fmt.Errorf("merkledag node was not a directory or shard")

// NewDirectoryFromNode loads a unixfs directory from the given IPLD node and
// DAGService.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.NewDirectoryFromNode
func NewDirectoryFromNode(dserv ipld.DAGService, node ipld.Node) (Directory, error) {
protoBufNode, ok := node.(*mdag.ProtoNode)
if !ok {
Expand Down Expand Up @@ -523,6 +539,8 @@ func (d *HAMTDirectory) sizeBelowThreshold(ctx context.Context, sizeChange int)
// DynamicDirectory wraps a Directory interface and provides extra logic
// to switch from BasicDirectory to HAMTDirectory and backwards based on
// size.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.DynamicDirectory
type DynamicDirectory struct {
Directory
}
Expand Down
2 changes: 2 additions & 0 deletions io/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

// ResolveUnixfsOnce resolves a single hop of a path through a graph in a
// unixfs context. This includes handling traversing sharded directories.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ResolveUnixfsOnce
func ResolveUnixfsOnce(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error) {
pn, ok := nd.(*dag.ProtoNode)
if ok {
Expand Down
11 changes: 9 additions & 2 deletions mod/dagmodifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ import (

// Common errors
var (
ErrSeekFail = errors.New("failed to seek properly")
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/mod.ErrSeekFail
ErrSeekFail = errors.New("failed to seek properly")
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/mod.ErrUnrecognizedWhence
ErrUnrecognizedWhence = errors.New("unrecognized whence")
ErrNotUnixfs = errors.New("dagmodifier only supports unixfs nodes (proto or raw)")
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/mod.ErrNotUnixfs
ErrNotUnixfs = errors.New("dagmodifier only supports unixfs nodes (proto or raw)")
)

// 2MB
Expand All @@ -32,6 +35,8 @@ var writebufferSize = 1 << 21
// DagModifier is the only struct licensed and able to correctly
// perform surgery on a DAG 'file'
// Dear god, please rename this to something more pleasant
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/mod.DagModifier
type DagModifier struct {
dagserv ipld.DAGService
curNode ipld.Node
Expand All @@ -54,6 +59,8 @@ type DagModifier struct {
// created nodes will be inhered from the passed in node. If the Cid
// version if not 0 raw leaves will also be enabled. The Prefix and
// RawLeaves options can be overridden by changing them after the call.
//
// Deprecated: use github.com/ipfs/boxo/ipld/unixfs/mod.NewDagModifier
func NewDagModifier(ctx context.Context, from ipld.Node, serv ipld.DAGService, spl chunker.SplitterGen) (*DagModifier, error) {
switch from.(type) {
case *mdag.ProtoNode, *mdag.RawNode:
Expand Down
Loading

0 comments on commit b08a89b

Please sign in to comment.