file

package
v0.14.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileV0 fileVersion = iota
)
View Source
const HeaderSize = 64

Variables

This section is empty.

Functions

func CloseOnceFile

func CloseOnceFile(f EdsFile) *closeOnceFile

func ReadEds

func ReadEds(_ context.Context, r io.Reader, edsSize int) (*rsmt2d.ExtendedDataSquare, error)

ReadEds reads an EDS from the reader and returns it.

Types

type CacheFile

type CacheFile struct {
	EdsFile
	// contains filtered or unexported fields
}

func NewCacheFile

func NewCacheFile(f EdsFile) *CacheFile

func (*CacheFile) AxisHalf

func (f *CacheFile) AxisHalf(ctx context.Context, axisType rsmt2d.Axis, axisIdx int) ([]share.Share, error)

func (*CacheFile) Data

func (f *CacheFile) Data(ctx context.Context, namespace share.Namespace, rowIdx int) (share.NamespacedRow, error)

func (*CacheFile) EDS

func (*CacheFile) Share

func (f *CacheFile) Share(ctx context.Context, x, y int) (*share.ShareWithProof, error)

type Codec

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

func NewCodec

func NewCodec() Codec

type EdsFile

type EdsFile interface {
	io.Closer
	// Reader returns binary reader for the file.
	Reader() (io.Reader, error)
	// Size returns square size of the file.
	Size() int
	// Height returns height of the file.
	Height() uint64
	// DataHash returns data hash of the file.
	DataHash() share.DataHash
	// Share returns share and corresponding proof for the given axis and share index in this axis.
	Share(ctx context.Context, x, y int) (*share.ShareWithProof, error)
	// AxisHalf returns shares for the first half of the axis of the given type and index.
	AxisHalf(ctx context.Context, axisType rsmt2d.Axis, axisIdx int) ([]share.Share, error)
	// Data returns data for the given namespace and row index.
	Data(ctx context.Context, namespace share.Namespace, rowIdx int) (share.NamespacedRow, error)
	// EDS returns extended data square stored in the file.
	EDS(ctx context.Context) (*rsmt2d.ExtendedDataSquare, error)
}
type Header struct {
	// contains filtered or unexported fields
}

func ReadHeader

func ReadHeader(r io.Reader) (*Header, error)

func (*Header) DataHash

func (h *Header) DataHash() share.DataHash

func (*Header) Height

func (h *Header) Height() uint64

func (*Header) ShareSize

func (h *Header) ShareSize() int

func (*Header) SquareSize

func (h *Header) SquareSize() int

func (*Header) Version

func (h *Header) Version() fileVersion

func (*Header) WriteTo

func (h *Header) WriteTo(w io.Writer) (int64, error)

type MemFile

type MemFile struct {
	Eds *rsmt2d.ExtendedDataSquare
	// contains filtered or unexported fields
}

func (*MemFile) AxisHalf

func (f *MemFile) AxisHalf(_ context.Context, axisType rsmt2d.Axis, axisIdx int) ([]share.Share, error)

func (*MemFile) Close

func (f *MemFile) Close() error

func (*MemFile) Data

func (f *MemFile) Data(_ context.Context, namespace share.Namespace, rowIdx int) (share.NamespacedRow, error)

func (*MemFile) DataHash

func (f *MemFile) DataHash() share.DataHash

func (*MemFile) EDS

func (*MemFile) Height

func (f *MemFile) Height() uint64

func (*MemFile) Reader

func (f *MemFile) Reader() (io.Reader, error)

func (*MemFile) Share

func (f *MemFile) Share(
	_ context.Context,
	x, y int,
) (*share.ShareWithProof, error)

func (*MemFile) Size

func (f *MemFile) Size() int

type OdsFile

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

func CreateOdsFile

func CreateOdsFile(
	path string,
	height uint64,
	datahash share.DataHash,
	eds *rsmt2d.ExtendedDataSquare) (*OdsFile, error)

func OpenOdsFile

func OpenOdsFile(path string) (*OdsFile, error)

OpenOdsFile opens an existing file. File has to be closed after usage.

func (*OdsFile) AxisHalf

func (f *OdsFile) AxisHalf(ctx context.Context, axisType rsmt2d.Axis, axisIdx int) ([]share.Share, error)

func (*OdsFile) Close

func (f *OdsFile) Close() error

func (*OdsFile) Data

func (f *OdsFile) Data(ctx context.Context, namespace share.Namespace, rowIdx int) (share.NamespacedRow, error)

func (*OdsFile) DataHash

func (f *OdsFile) DataHash() share.DataHash

func (*OdsFile) EDS

func (*OdsFile) Height

func (f *OdsFile) Height() uint64

func (*OdsFile) Reader

func (f *OdsFile) Reader() (io.Reader, error)

func (*OdsFile) Share

func (f *OdsFile) Share(ctx context.Context, x, y int) (*share.ShareWithProof, error)

func (*OdsFile) Size

func (f *OdsFile) Size() int

Jump to

Keyboard shortcuts

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