file

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateODS

func CreateODS(
	path string,
	roots *share.AxisRoots,
	eds *rsmt2d.ExtendedDataSquare,
) error

CreateODS creates a new file under given FS path and writes the ODS into it out of given EDS. It may leave partially written file if any of the writes fail.

func CreateODSQ4

func CreateODSQ4(
	pathODS, pathQ4 string,
	roots *share.AxisRoots,
	eds *rsmt2d.ExtendedDataSquare,
) error

CreateODSQ4 creates ODS and Q4 files under the given FS paths.

func ValidateODSQ4Size

func ValidateODSQ4Size(pathODS, pathQ4 string, eds *rsmt2d.ExtendedDataSquare) error

ValidateODSQ4Size checks the size of the ODS and Q4 files under the given FS paths.

func ValidateODSSize

func ValidateODSSize(path string, eds *rsmt2d.ExtendedDataSquare) error

ValidateODSSize checks if the file under given FS path has the expected size.

Types

type Codec

type Codec interface {
	Encoder(len int) (reedsolomon.Encoder, error)
}

func NewCodec

func NewCodec() Codec

type ODS

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

ODS implements eds.Accessor as an FS file. It stores the original data square(ODS), which is the first quadrant of EDS, and it's metadata in file's header.

func OpenODS

func OpenODS(path string) (*ODS, error)

OpenODS opens an existing ODS file under given FS path. It only reads the header with metadata. The other content of the File is read lazily. If file is empty, the ErrEmptyFile is returned. File must be closed after usage.

func (*ODS) AxisHalf

func (o *ODS) AxisHalf(_ context.Context, axisType rsmt2d.Axis, axisIdx int) (eds.AxisHalf, error)

AxisHalf returns half of shares axis of the given type and index. Side is determined by implementation. Implementations should indicate the side in the returned AxisHalf.

func (*ODS) AxisRoots

func (o *ODS) AxisRoots(context.Context) (*share.AxisRoots, error)

AxisRoots reads AxisRoots stored in the file. AxisRoots are stored after the header and before the ODS data.

func (*ODS) Close

func (o *ODS) Close() error

Close closes the file.

func (*ODS) DataHash

func (o *ODS) DataHash(context.Context) (share.DataHash, error)

DataHash returns root hash of Accessor's underlying EDS.

func (*ODS) Reader

func (o *ODS) Reader() (io.Reader, error)

Reader returns binary reader for the file. It reads the shares from the ODS part of the square row by row.

func (*ODS) RowNamespaceData

func (o *ODS) RowNamespaceData(
	ctx context.Context,
	namespace libshare.Namespace,
	rowIdx int,
) (shwap.RowNamespaceData, error)

RowNamespaceData returns data for the given namespace and row index.

func (*ODS) Sample

func (o *ODS) Sample(ctx context.Context, rowIdx, colIdx int) (shwap.Sample, error)

Sample returns share and corresponding proof for row and column indices. Implementation can choose which axis to use for proof. Chosen axis for proof should be indicated in the returned Sample.

func (*ODS) Shares

func (o *ODS) Shares(context.Context) ([]libshare.Share, error)

Shares returns data shares extracted from the Accessor.

func (*ODS) Size

func (o *ODS) Size(context.Context) int

Size returns EDS size stored in file's header.

type ODSQ4

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

ODSQ4 is an Accessor that combines ODS and Q4 files. It extends the ODS with the ability to read Q4 of the EDS. Reading from the fourth quadrant allows to efficiently read samples from Q2 and Q4 quadrants of the square, as well as reading columns from Q3 and Q4 quadrants. Reading from Q4 in those cases is more efficient than reading from Q1, because it would require reading the whole Q1 quadrant and reconstructing the data from it. It opens Q4 file lazily on the first read attempt.

func ODSWithQ4

func ODSWithQ4(ods *ODS, pathQ4 string) *ODSQ4

ODSWithQ4 returns ODSQ4 instance over ODS. It opens Q4 file lazily under the given path.

func (*ODSQ4) AxisHalf

func (odsq4 *ODSQ4) AxisHalf(ctx context.Context, axisType rsmt2d.Axis, axisIdx int) (eds.AxisHalf, error)

func (*ODSQ4) AxisRoots

func (odsq4 *ODSQ4) AxisRoots(ctx context.Context) (*share.AxisRoots, error)

func (*ODSQ4) Close

func (odsq4 *ODSQ4) Close() error

func (*ODSQ4) DataHash

func (odsq4 *ODSQ4) DataHash(ctx context.Context) (share.DataHash, error)

func (*ODSQ4) Reader

func (odsq4 *ODSQ4) Reader() (io.Reader, error)

func (*ODSQ4) RowNamespaceData

func (odsq4 *ODSQ4) RowNamespaceData(ctx context.Context,
	namespace libshare.Namespace,
	rowIdx int,
) (shwap.RowNamespaceData, error)

func (*ODSQ4) Sample

func (odsq4 *ODSQ4) Sample(ctx context.Context, rowIdx, colIdx int) (shwap.Sample, error)

func (*ODSQ4) Shares

func (odsq4 *ODSQ4) Shares(ctx context.Context) ([]libshare.Share, error)

func (*ODSQ4) Size

func (odsq4 *ODSQ4) Size(ctx context.Context) int

Jump to

Keyboard shortcuts

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