storage

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0, MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsIdentity

func AsIdentity(key string) (digest []byte, ok bool, err error)

Types

type CachingTempStore

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

CachingTempStore is a ReadableWritableStorage that is intended for temporary use. It uses DeferredStorageCar as a backing store, so the underlying CAR file is lazily created on the first write (none will be created if there are no writes).

A provided BlockWriteOpener will receive blocks for each Put operation, this is intended to be used to write a properly ordered CARv1 file.

func NewCachingTempStore

func NewCachingTempStore(outWriter linking.BlockWriteOpener, store *DeferredStorageCar) *CachingTempStore

func (*CachingTempStore) Close

func (ttrw *CachingTempStore) Close() error

Close will clean up any temporary resources used by the storage.

func (*CachingTempStore) Get

func (ttrw *CachingTempStore) Get(ctx context.Context, key string) ([]byte, error)

func (*CachingTempStore) GetStream

func (ttrw *CachingTempStore) GetStream(ctx context.Context, key string) (io.ReadCloser, error)

func (*CachingTempStore) Has

func (ttrw *CachingTempStore) Has(ctx context.Context, key string) (bool, error)

func (*CachingTempStore) Put

func (ttrw *CachingTempStore) Put(ctx context.Context, key string, data []byte) error

Put writes both to temporary readwrite caching storage (available for read operations) and to the underlying write-only CARv1 output at the same time.

type DeferredStorageCar

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

DeferredStorageCar is a wrapper around github.com/ipld/go-car/v2/storage.StorageCar that defers creating the CAR until the first Put() operation. In this way it can be optimistically instantiated and no file will be created if it is never written to (such as in the case of an error).

func NewDeferredStorageCar

func NewDeferredStorageCar(tempDir string, root cid.Cid) *DeferredStorageCar

NewDeferredStorageCar creates a new DeferredStorageCar.

func (*DeferredStorageCar) Close

func (dcs *DeferredStorageCar) Close() error

Close will clean up any temporary resources used by the storage.

func (*DeferredStorageCar) Get

func (dcs *DeferredStorageCar) Get(ctx context.Context, key string) ([]byte, error)

Get returns data from the underlying CARv1.

func (*DeferredStorageCar) GetStream

func (dcs *DeferredStorageCar) GetStream(ctx context.Context, key string) (io.ReadCloser, error)

GetStream returns data from the underlying CARv1.

func (*DeferredStorageCar) Has

func (dcs *DeferredStorageCar) Has(ctx context.Context, key string) (bool, error)

Has returns true if the underlying CARv1 has the key.

func (*DeferredStorageCar) Put

func (dcs *DeferredStorageCar) Put(ctx context.Context, key string, data []byte) error

Put writes data to the underlying CARv1 which will be initialised on the first call to Put.

type DeferredWriter

type DeferredWriter interface {
	ipldstorage.WritableStorage
	io.Closer
	BlockWriteOpener() linking.BlockWriteOpener
	OnPut(cb func(int), once bool)
}

type DuplicateAdderCar

type DuplicateAdderCar struct {
	*deferred.DeferredCarWriter
	// contains filtered or unexported fields
}

func NewDuplicateAdderCarForPath

func NewDuplicateAdderCarForPath(
	ctx context.Context,
	outPath string,
	root cid.Cid,
	path string,
	scope trustlessutils.DagScope,
	bytes *trustlessutils.ByteRange,
	store *DeferredStorageCar,
) *DuplicateAdderCar

func NewDuplicateAdderCarForStream

func NewDuplicateAdderCarForStream(
	ctx context.Context,
	outStream io.Writer,
	root cid.Cid,
	path string,
	scope trustlessutils.DagScope,
	bytes *trustlessutils.ByteRange,
	store *DeferredStorageCar,
) *DuplicateAdderCar

func (*DuplicateAdderCar) BlockWriteOpener

func (da *DuplicateAdderCar) BlockWriteOpener() linking.BlockWriteOpener

func (*DuplicateAdderCar) Close

func (da *DuplicateAdderCar) Close() error

Close closes the dup stream, verifying completion, if one was created.

Jump to

Keyboard shortcuts

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