Documentation
¶
Index ¶
- Variables
- func BlockSizes(b *Builder, blockSizes []uint64)
- func BuildUnixFS(fn func(*Builder)) (data.UnixFSData, error)
- func BuildUnixFSDirectory(entries []dagpb.PBLink, ls *ipld.LinkSystem) (ipld.Link, uint64, error)
- func BuildUnixFSDirectoryEntry(name string, size int64, hash ipld.Link) (dagpb.PBLink, error)
- func BuildUnixFSFile(r io.Reader, chunker string, ls *ipld.LinkSystem) (ipld.Link, uint64, error)
- func BuildUnixFSRecursive(root string, ls *ipld.LinkSystem) (ipld.Link, uint64, error)
- func BuildUnixFSShardedDirectory(size int, hasher uint64, entries []dagpb.PBLink, ls *ipld.LinkSystem) (ipld.Link, uint64, error)
- func BuildUnixFSSymlink(content string, ls *ipld.LinkSystem) (ipld.Link, uint64, error)
- func Data(b *Builder, dataBytes []byte)
- func DataType(b *Builder, dataType int64)
- func Fanout(b *Builder, fanout uint64)
- func FileSize(b *Builder, fileSize uint64)
- func FractionalNanoseconds(ma TimeBuilder, nanoseconds int32)
- func HashType(b *Builder, hashType uint64)
- func Mtime(b *Builder, fn func(tb TimeBuilder))
- func Permissions(b *Builder, mode int)
- func PermissionsString(b *Builder, modeString string)
- func Seconds(ma TimeBuilder, seconds int64)
- func Time(ma TimeBuilder, t time.Time)
- type Builder
- type TimeBuilder
Constants ¶
This section is empty.
Variables ¶
var BlockSizeLimit = 1048576 // 1 MB
BlockSizeLimit specifies the maximum size an imported block can have.
var DefaultLinksPerBlock = roughLinkBlockSize / roughLinkSize
DefaultLinksPerBlock governs how the importer decides how many links there will be per block. This calculation is based on expected distributions of:
- the expected distribution of block sizes
- the expected distribution of link sizes
- desired access speed
For now, we use:
var roughLinkBlockSize = 1 << 13 // 8KB var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name // + protobuf framing var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize) = ( 8192 / 47 ) = (approximately) 174
Functions ¶
func BlockSizes ¶
BlockSizes encodes block sizes for each child node
func BuildUnixFS ¶
func BuildUnixFS(fn func(*Builder)) (data.UnixFSData, error)
BuildUnixFS provides a clean, validated interface to building data structures that match the UnixFS protobuf encoded in the Data member of a ProtoNode with sensible defaults
smallFileData, err := BuildUnixFS(func(b *Builder) { Data(b, []byte{"hello world"}) Mtime(b, func(tb TimeBuilder) { Time(tb, time.Now()) }) })
func BuildUnixFSDirectory ¶
BuildUnixFSDirectory creates a directory link over a collection of entries.
func BuildUnixFSDirectoryEntry ¶
BuildUnixFSDirectoryEntry creates the link to a file or directory as it appears within a unixfs directory.
func BuildUnixFSFile ¶
BuildUnixFSFile creates a dag of ipld Nodes representing file data. This recreates the functionality previously found in github.com/ipfs/go-unixfs/importer/balanced, but tailored to the go-unixfsnode & ipld-prime data layout of nodes. We make some assumptions in building files with this builder to reduce complexity, namely:
- we assume we are using CIDv1, which has implied that the leaf data nodes are stored as raw bytes. ref: https://github.com/ipfs/go-mfs/blob/1b1fd06cff048caabeddb02d4dbf22d2274c7971/file.go#L50
func BuildUnixFSRecursive ¶
BuildUnixFSRecursive returns a link pointing to the UnixFS node representing the file or directory tree pointed to by `root`
func BuildUnixFSShardedDirectory ¶
func BuildUnixFSShardedDirectory(size int, hasher uint64, entries []dagpb.PBLink, ls *ipld.LinkSystem) (ipld.Link, uint64, error)
BuildUnixFSShardedDirectory will build a hamt of unixfs hamt shards encoing a directory with more entries than is typically allowed to fit in a standard IPFS single-block unixFS directory.
func BuildUnixFSSymlink ¶
BuildUnixFSSymlink builds a symlink entry in a unixfs tree
func FileSize ¶
FileSize sets the file size which should be the size of actual bytes underneath this node for large files, w/o additional bytes to encode intermediate nodes
func FractionalNanoseconds ¶
func FractionalNanoseconds(ma TimeBuilder, nanoseconds int32)
FractionalNanoseconds sets the nanoseconds for a modification time (must be between 0 & a billion)
func Mtime ¶
func Mtime(b *Builder, fn func(tb TimeBuilder))
Mtime sets the modification time for this node using the time builder interface and associated methods
func Permissions ¶
Permissions sets file permissions for the Mode member of the UnixFS node
func PermissionsString ¶
PermissionsString sets file permissions for the Mode member of the UnixFS node, parsed from a typical octect encoded permission string (eg '0755')
func Seconds ¶
func Seconds(ma TimeBuilder, seconds int64)
Seconds sets the seconds for a modification time
func Time ¶
func Time(ma TimeBuilder, t time.Time)
Time sets the modification time from a golang time value
Types ¶
type Builder ¶
type Builder struct { ipld.MapAssembler // contains filtered or unexported fields }
Builder is an interface for making UnixFS data nodes
type TimeBuilder ¶
type TimeBuilder ipld.MapAssembler
TimeBuilder is a simple interface for constructing the time member of UnixFS data