rsec16

package
v0.0.0-...-a776223 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultNumGoroutines

func DefaultNumGoroutines() int

DefaultNumGoroutines returns a default value for the numGoroutines parameter to pass into NewCoderCauchy and NewCoderPAR2Vandermonde. This is not necessarily GOMAXPROCS.

Types

type Coder

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

A Coder is an object that can generate parity shards, verify parity shards, and reconstruct data shards from parity shards.

func NewCoderCauchy

func NewCoderCauchy(dataShards, parityShards, numGoroutines int) (Coder, error)

NewCoderCauchy returns a Coder that works with the given number of data and parity shards, using a Cauchy matrix.

func NewCoderPAR2Vandermonde

func NewCoderPAR2Vandermonde(dataShards, parityShards, numGoroutines int) (Coder, error)

NewCoderPAR2Vandermonde returns a Coder that works with the given number of data and parity shards, using a Vandermonde matrix as specified in the PAR2 spec. Note that this matrix is flawed, so ReconstructData may fail.

func (Coder) GenerateParity

func (c Coder) GenerateParity(data [][]byte) [][]byte

GenerateParity takes a list of data shards, which must have length matching the dataShards value passed into NewCoder, and which must have equal-sized byte slices with even length, and returns a list of parityShards parity shards.

func (Coder) ReconstructData

func (c Coder) ReconstructData(data, parity [][]byte) error

ReconstructData takes a list of data shards and parity shards, some of which may be nil, and tries to reconstruct the missing data shards. If successful, the nil rows of data are filled in and a nil error is returned. Otherwise, an error is returned. In particular, if there are missing data shards but there aren't enough parity shards to reconstruct them, NotEnoughParityShardsError is returned.

type NotEnoughParityShardsError

type NotEnoughParityShardsError struct{}

NotEnoughParityShardsError is returned by ReconstructData or if there isn't enough parity shards to reconstruct some missing data.

func (NotEnoughParityShardsError) Error

Jump to

Keyboard shortcuts

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