bigblob

package
v0.0.0-...-6e0c3d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2023 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DEKSize = 32
View Source
const RefSize = cadata.IDSize + DEKSize

RefSize is the size of a Ref marshalled to binary

Variables

This section is empty.

Functions

func DeriveKey

func DeriveKey(out []byte, salt *[32]byte, input []byte)

DeriveKey uses BLAKE3 keyed with salt, to absorb input, and derive a new key into out

Types

type AddExister

type AddExister interface {
	cadata.Adder
	cadata.Exister
}

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent(opts ...Option) *Agent

func (*Agent) Concat

func (ag *Agent) Concat(ctx context.Context, s cadata.Store, blockSize int, salt *[32]byte, roots ...Root) (*Root, error)

func (*Agent) Create

func (ag *Agent) Create(ctx context.Context, s cadata.Poster, salt *[32]byte, r io.Reader) (*Root, error)

Create creates a Blob and returns it's Root.

func (*Agent) NewReader

func (ag *Agent) NewReader(ctx context.Context, s cadata.Getter, root Root) *Reader

func (*Agent) NewWriter

func (ag *Agent) NewWriter(s cadata.Poster, salt *[32]byte) *Writer

func (*Agent) Populate

func (ag *Agent) Populate(ctx context.Context, s cadata.Getter, root Root, dst AddExister) error

func (*Agent) ReadAt

func (ag *Agent) ReadAt(ctx context.Context, s cadata.Getter, x Root, offset int64, buf []byte) (n int, err error)

func (*Agent) Sync

func (ag *Agent) Sync(ctx context.Context, dst cadata.Store, src cadata.Getter, x Root, fn func(r *Reader) error) error

func (*Agent) Traverse

func (ag *Agent) Traverse(ctx context.Context, s cadata.Getter, sem *semaphore.Weighted, root Root, tr Traverser) error

type DEK

type DEK [DEKSize]byte

func (DEK) MarshalJSON

func (dek DEK) MarshalJSON() (ret []byte, _ error)

func (*DEK) UnmarshalJSON

func (dek *DEK) UnmarshalJSON(data []byte) error

type Index

type Index struct {
	// contains filtered or unexported fields
}

func (Index) Clear

func (idx Index) Clear()

func (Index) Get

func (idx Index) Get(i int) Ref

func (Index) Len

func (idx Index) Len() int

func (Index) Set

func (idx Index) Set(i int, ref Ref)

type Option

type Option func(*Agent)

func WithBlockSize

func WithBlockSize(n int) Option

WithBlockSize sets the block size used when writing files. If n < 0 then WithBlockSize panics If n == 0 then the stores MaxBlobSize will be used as a default.

func WithCacheSize

func WithCacheSize(n int) Option

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func (*Reader) Read

func (r *Reader) Read(data []byte) (int, error)

func (*Reader) ReadAt

func (r *Reader) ReadAt(data []byte, at int64) (int, error)

func (*Reader) Seek

func (r *Reader) Seek(offset int64, whence int) (int64, error)

type Ref

type Ref struct {
	CID cadata.ID `json:"cid"`
	DEK DEK       `json:"dek"`
}

Ref is a reference to data in a content-addressed store

func RefFromBytes

func RefFromBytes(x []byte) (*Ref, error)

func (Ref) Equals

func (r1 Ref) Equals(r2 Ref) bool

func (Ref) Key

func (r Ref) Key() (ret [32]byte)

func (Ref) MarshalBinary

func (r Ref) MarshalBinary() ([]byte, error)

type Root

type Root struct {
	Ref
	Size      uint64 `json:"size"`
	BlockSize uint64 `json:"blockSize"`
}

Root is the root of a blob represented as a tree of fixed sized content-addressed blocks

func (Root) Equals

func (r1 Root) Equals(r2 Root) bool

func (Root) String

func (r Root) String() string

type Traverser

type Traverser struct {
	// If Enter returns false the node is skipped
	Enter func(ctx context.Context, id cadata.ID) (bool, error)
	Exit  func(ctx context.Context, level int, ref Ref) error
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func (*Writer) Finish

func (w *Writer) Finish(ctx context.Context) (*Root, error)

func (*Writer) SetWriteContext

func (w *Writer) SetWriteContext(ctx context.Context)

func (*Writer) Write

func (w *Writer) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL