erasurecode

package
v0.0.0-...-0352b5b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const MaxShardCount = 256

MaxShardCount is the maximum number of shards.

Variables

View Source
var (
	// ErrMalformedSlice is returned when a slice of EC chunks is inconsistent.
	ErrMalformedSlice = errors.New("inconsistent EC headers")
	// ErrInvShardNum is returned from NewConstructor when the number of shards is invalid.
	ErrInvShardNum = reedsolomon.ErrInvShardNum
	// ErrMaxShardNum is returned from NewConstructor when the number of shards is too big.
	ErrMaxShardNum = reedsolomon.ErrMaxShardNum
)

Functions

This section is empty.

Types

type Constructor

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

Constructor is a wrapper around encoder allowing to reconstruct objects. It's methods are not thread-safe.

func NewConstructor

func NewConstructor(dataCount int, parityCount int) (*Constructor, error)

NewConstructor returns new constructor instance.

func (*Constructor) Reconstruct

func (c *Constructor) Reconstruct(parts []*objectSDK.Object) (*objectSDK.Object, error)

Reconstruct returns full object reconstructed from parts. All non-nil objects in parts must have EC header with the same `total` field equal to len(parts). The slice must contain at least one non nil object. Index of the objects in parts must be equal to it's index field in the EC header. The parts slice isn't changed and can be used concurrently for reading.

func (*Constructor) ReconstructHeader

func (c *Constructor) ReconstructHeader(parts []*objectSDK.Object) (*objectSDK.Object, error)

ReconstructHeader returns object header reconstructed from parts. All non-nil objects in parts must have EC header with the same `total` field equal to len(parts). The slice must contain at least one non nil object. Index of the objects in parts must be equal to it's index field in the EC header. The parts slice isn't changed and can be used concurrently for reading.

func (*Constructor) ReconstructParts

func (c *Constructor) ReconstructParts(parts []*objectSDK.Object, required []bool, key *ecdsa.PrivateKey) error

ReconstructParts reconstructs specific EC parts without reconstructing full object. All non-nil objects in parts must have EC header with the same `total` field equal to len(parts). The slice must contain at least one non nil object. Index of the objects in parts must be equal to it's index field in the EC header. Those parts for which corresponding element in required is true must be nil and will be overwritten. Because partial reconstruction only makes sense for full objects, all parts must have non-empty payload. If key is not nil, all reconstructed parts are signed with this key.

func (*Constructor) Split

func (c *Constructor) Split(obj *objectSDK.Object, key *ecdsa.PrivateKey) ([]*objectSDK.Object, error)

Split splits fully formed object into multiple chunks.

func (*Constructor) Verify

func (c *Constructor) Verify(parts []*objectSDK.Object) error

Verify verifies that parts are well formed. All parts are expected to be non-nil. The number of parts must be equal to `total` field of the EC header and parts must be sorted by index.

type ObjectWriter

type ObjectWriter interface {
	WriteObject(context.Context, *objectSDK.Object) error
}

ObjectWriter is an interface of the object writer that writes prepared object.

type Target

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

Target accepts regular objects and splits them into erasure-coded chunks.

func NewTarget

func NewTarget(c *Constructor, key *ecdsa.PrivateKey, next ObjectWriter) *Target

NewTarget returns new target instance.

func (*Target) WriteObject

func (t *Target) WriteObject(ctx context.Context, obj *objectSDK.Object) error

WriteObject implements the transformer.ObjectWriter interface.

Jump to

Keyboard shortcuts

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