blobs

package
v0.37.4-pr6379 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const CidLength = 34

CidLength is the length of a CID in bytes

Variables

View Source
var ErrBlobChannelWriterClosed = errors.New("blob channel writer is already closed")
View Source
var ErrNotFound = errors.New("blobstore: blob not found")
View Source
var NewBlob = blocks.NewBlock

Functions

func NewBlobstore added in v0.27.2

func NewBlobstore(ds datastore.Batching) *blobstoreImpl

Types

type Blob

type Blob = blocks.Block

type BlobChannelReader

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

BlobChannelReader is a reader which reads data from a blob channel.

func NewBlobChannelReader added in v0.27.2

func NewBlobChannelReader(blobChan <-chan Blob) *BlobChannelReader

func (*BlobChannelReader) BytesReceived added in v0.27.2

func (br *BlobChannelReader) BytesReceived() uint64

func (*BlobChannelReader) CidsReceived added in v0.27.2

func (br *BlobChannelReader) CidsReceived() []cid.Cid

func (*BlobChannelReader) Read

func (br *BlobChannelReader) Read(data []byte) (int, error)

Read reads up to len(data) bytes from the underlying blob channel into data. It returns the number of bytes read (0 <= n <= len(data)) and any error encountered. Returns io.EOF if the incoming blob channel was closed and all available data has been read.

func (*BlobChannelReader) ReadByte

func (br *BlobChannelReader) ReadByte() (byte, error)

ReadByte reads a single byte from the underlying blob channel. It returns an error if the byte could not be read. Returns io.EOF if the incoming blob channel was closed and all available data has been read.

type BlobChannelWriter

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

BlobChannelWriter is a writer which splits the data written to it into blobs and sends them to a blob channel.

func NewBlobChannelWriter added in v0.27.2

func NewBlobChannelWriter(blobChan chan<- Blob, maxBlobSize int) *BlobChannelWriter

func (*BlobChannelWriter) BytesSent added in v0.27.2

func (bw *BlobChannelWriter) BytesSent() uint64

func (*BlobChannelWriter) CidsSent added in v0.27.2

func (bw *BlobChannelWriter) CidsSent() []cid.Cid

func (*BlobChannelWriter) Close

func (bw *BlobChannelWriter) Close() error

Close flushes any buffered data to the underlying blob channel and closes the blob channel.

func (*BlobChannelWriter) Flush

func (bw *BlobChannelWriter) Flush() error

Flush flushes any buffered data to the underlying blob channel as a new blob. It returns an error if the flush failed. Returns ErrBlobChannelWriterClosed if the Blob Channel Writer was already previously closed via a call to Close

func (*BlobChannelWriter) Write

func (bw *BlobChannelWriter) Write(data []byte) (int, error)

Write writes len(data) bytes from data to the underlying blob channel. It returns the number of bytes written from data (0 <= n <= len(data)) or ErrBlobChannelWriterClosed if the Blob Channel Writer was already previously closed via a call to Close. It will always return a non-nil error if it returns n < len(data).

func (*BlobChannelWriter) WriteByte

func (bw *BlobChannelWriter) WriteByte(c byte) error

WriteByte writes a single byte to the underlying blob channel. It returns an error if the byte could not be written. Returns ErrBlobChannelWriterClosed if the Blob Channel Writer was already previously closed via a call to Close

type Blobstore added in v0.27.2

type Blobstore interface {
	DeleteBlob(context.Context, cid.Cid) error
	Has(context.Context, cid.Cid) (bool, error)
	Get(context.Context, cid.Cid) (Blob, error)

	// GetSize returns the CIDs mapped BlobSize
	GetSize(context.Context, cid.Cid) (int, error)

	// Put puts a given blob to the underlying datastore
	Put(context.Context, Blob) error

	// PutMany puts a slice of blobs at the same time using batching
	// capabilities of the underlying datastore whenever possible.
	PutMany(context.Context, []Blob) error

	// AllKeysChan returns a channel from which
	// the CIDs in the Blobstore can be read. It should respect
	// the given context, closing the channel if it becomes Done.
	AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

	// HashOnRead specifies if every read blob should be
	// rehashed to make sure it matches its CID.
	HashOnRead(enabled bool)
}

type NoopBlobstore added in v0.29.10

type NoopBlobstore struct{}

NoopBlobstore is a Blobstore that does nothing, which is useful for calculating BlockExecutionData IDs without storing the data.

func NewNoopBlobstore added in v0.32.0

func NewNoopBlobstore() *NoopBlobstore

func (*NoopBlobstore) AllKeysChan added in v0.29.10

func (n *NoopBlobstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

func (*NoopBlobstore) DeleteBlob added in v0.29.10

func (n *NoopBlobstore) DeleteBlob(context.Context, cid.Cid) error

func (*NoopBlobstore) Get added in v0.29.10

func (n *NoopBlobstore) Get(context.Context, cid.Cid) (Blob, error)

func (*NoopBlobstore) GetSize added in v0.29.10

func (n *NoopBlobstore) GetSize(context.Context, cid.Cid) (int, error)

func (*NoopBlobstore) Has added in v0.29.10

func (n *NoopBlobstore) Has(context.Context, cid.Cid) (bool, error)

func (*NoopBlobstore) HashOnRead added in v0.29.10

func (n *NoopBlobstore) HashOnRead(enabled bool)

func (*NoopBlobstore) Put added in v0.29.10

func (*NoopBlobstore) PutMany added in v0.29.10

func (n *NoopBlobstore) PutMany(context.Context, []Blob) error

Jump to

Keyboard shortcuts

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