pieces

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: AGPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("pieces error")

Error is the default error class.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Add inserts Info to the database.
	Add(context.Context, *Info) error
	// Get returns Info about a piece.
	Get(ctx context.Context, satelliteID storj.NodeID, pieceID storj.PieceID) (*Info, error)
	// Delete deletes Info about a piece.
	Delete(ctx context.Context, satelliteID storj.NodeID, pieceID storj.PieceID) error
	// DeleteFailed marks piece deletion from disk failed
	DeleteFailed(ctx context.Context, satelliteID storj.NodeID, pieceID storj.PieceID, failedAt time.Time) error
	// SpaceUsed calculates disk space used by all pieces
	SpaceUsed(ctx context.Context) (int64, error)
	// GetExpired gets orders that are expired and were created before some time
	GetExpired(ctx context.Context, expiredAt time.Time, limit int64) ([]ExpiredInfo, error)
}

DB stores meta information about a piece, the actual piece is stored in storage.Blobs

type ExpiredInfo added in v0.11.0

type ExpiredInfo struct {
	SatelliteID storj.NodeID
	PieceID     storj.PieceID
	PieceSize   int64
}

ExpiredInfo is a fully namespaced piece id

type Info

type Info struct {
	SatelliteID storj.NodeID

	PieceID         storj.PieceID
	PieceSize       int64
	PieceExpiration *time.Time

	UplinkPieceHash *pb.PieceHash
	Uplink          *identity.PeerIdentity
}

Info contains all the information we need to know about a Piece to manage them.

type Reader

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

Reader implements a piece reader that reads content from blob store.

func NewReader

func NewReader(blob storage.BlobReader, bufferSize int) (*Reader, error)

NewReader creates a new reader for storage.BlobReader.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the reader.

func (*Reader) Read

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

Read reads data from the underlying blob, buffering as necessary.

func (*Reader) ReadAt

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

ReadAt reads data at the specified offset

func (*Reader) Seek

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

Seek seeks to the specified location.

func (*Reader) Size

func (r *Reader) Size() int64

Size returns the amount of data written so far.

type StorageStatus

type StorageStatus struct {
	DiskUsed int64
	DiskFree int64
}

StorageStatus contains information about the disk store is using.

type Store

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

Store implements storing pieces onto a blob storage implementation.

func NewStore

func NewStore(log *zap.Logger, blobs storage.Blobs) *Store

NewStore creates a new piece store

func (*Store) Delete

func (store *Store) Delete(ctx context.Context, satellite storj.NodeID, pieceID storj.PieceID) error

Delete deletes the specified piece.

func (*Store) Reader

func (store *Store) Reader(ctx context.Context, satellite storj.NodeID, pieceID storj.PieceID) (*Reader, error)

Reader returns a new piece reader.

func (*Store) StorageStatus

func (store *Store) StorageStatus() (StorageStatus, error)

StorageStatus returns information about the disk.

func (*Store) Writer

func (store *Store) Writer(ctx context.Context, satellite storj.NodeID, pieceID storj.PieceID) (*Writer, error)

Writer returns a new piece writer.

type Writer

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

Writer implements a piece writer that writes content to blob store and calculates a hash.

func NewWriter

func NewWriter(blob storage.BlobWriter, bufferSize int) (*Writer, error)

NewWriter creates a new writer for storage.BlobWriter.

func (*Writer) Cancel

func (w *Writer) Cancel() error

Cancel deletes any temporarily written data.

func (*Writer) Commit

func (w *Writer) Commit() error

Commit commits piece to permanent storage.

func (*Writer) Hash

func (w *Writer) Hash() []byte

Hash returns the hash of data written so far.

func (*Writer) Size

func (w *Writer) Size() int64

Size returns the amount of data written so far.

func (*Writer) Write

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

Write writes data to the blob and calculates the hash.

Jump to

Keyboard shortcuts

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