Documentation ¶
Index ¶
- Variables
- func BenchGetHalfAxisFromAccessor(ctx context.Context, b *testing.B, createAccessor createAccessor, ...)
- func BenchGetSampleFromAccessor(ctx context.Context, b *testing.B, createAccessor createAccessor, ...)
- func NamespaceData(ctx context.Context, eds Accessor, namespace libshare.Namespace) (shwap.NamespaceData, error)
- func ProveShares(eds *rsmt2d.ExtendedDataSquare, start, end int) (*types.ShareProof, error)
- func ReadShares(r io.Reader, shareSize, odsSize int) ([]libshare.Share, error)
- func TestStreamer(ctx context.Context, t *testing.T, create createAccessorStreamer, odsSize int)
- func TestSuiteAccessor(ctx context.Context, t *testing.T, createAccessor createAccessor, maxSize int)
- type Accessor
- type AccessorStreamer
- type AxisHalf
- type Retriever
- type Rsmt2D
- func (eds *Rsmt2D) AxisHalf(_ context.Context, axisType rsmt2d.Axis, axisIdx int) (AxisHalf, error)
- func (eds *Rsmt2D) AxisRoots(context.Context) (*share.AxisRoots, error)
- func (eds *Rsmt2D) Close() error
- func (eds *Rsmt2D) DataHash(context.Context) (share.DataHash, error)
- func (eds *Rsmt2D) HalfRow(idx int, side shwap.RowSide) (shwap.Row, error)
- func (eds *Rsmt2D) Reader() (io.Reader, error)
- func (eds *Rsmt2D) RowNamespaceData(_ context.Context, namespace libshare.Namespace, rowIdx int) (shwap.RowNamespaceData, error)
- func (eds *Rsmt2D) Sample(_ context.Context, idx shwap.SampleCoords) (shwap.Sample, error)
- func (eds *Rsmt2D) SampleForProofAxis(idx shwap.SampleCoords, proofType rsmt2d.Axis) (shwap.Sample, error)
- func (eds *Rsmt2D) Shares(_ context.Context) ([]libshare.Share, error)
- func (eds *Rsmt2D) Size(context.Context) int
- type ShareReader
- type Streamer
Constants ¶
This section is empty.
Variables ¶
var EmptyAccessor = &Rsmt2D{ExtendedDataSquare: share.EmptyEDS()}
EmptyAccessor is an accessor of an empty EDS block.
var RetrieveQuadrantTimeout = blockTime / numQuadrants * 2
RetrieveQuadrantTimeout defines how much time Retriever waits before starting to retrieve another quadrant.
NOTE: - The whole data square must be retrieved in less than block time. - We have 4 quadrants from two sources(rows, cols) which equals to 8 in total.
Functions ¶
func BenchGetHalfAxisFromAccessor ¶ added in v0.20.2
func BenchGetSampleFromAccessor ¶ added in v0.20.2
func NamespaceData ¶ added in v0.20.2
func NamespaceData( ctx context.Context, eds Accessor, namespace libshare.Namespace, ) (shwap.NamespaceData, error)
NamespaceData extracts shares for a specific namespace from an EDS, considering each row independently. It uses root to determine which rows to extract data from, avoiding the need to recalculate the row roots for each row.
func ProveShares ¶ added in v0.15.0
func ProveShares(eds *rsmt2d.ExtendedDataSquare, start, end int) (*types.ShareProof, error)
ProveShares generates a share proof for a share range. The share range, defined by start and end, is end-exclusive.
func ReadShares ¶ added in v0.20.2
ReadShares reads shares from the provided io.Reader until EOF. If EOF is reached, the remaining shares are populated as tail padding shares. Provided reader must contain shares in row-major order.
func TestStreamer ¶ added in v0.20.2
Types ¶
type Accessor ¶ added in v0.20.2
type Accessor interface { // Size returns square size of the Accessor. Size(ctx context.Context) int // DataHash returns data hash of the Accessor. DataHash(ctx context.Context) (share.DataHash, error) // AxisRoots returns share.AxisRoots (DataAvailabilityHeader) of the Accessor. AxisRoots(ctx context.Context) (*share.AxisRoots, 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. Sample(ctx context.Context, idx shwap.SampleCoords) (shwap.Sample, 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. AxisHalf(ctx context.Context, axisType rsmt2d.Axis, axisIdx int) (AxisHalf, error) // RowNamespaceData returns data for the given namespace and row index. RowNamespaceData(ctx context.Context, namespace libshare.Namespace, rowIdx int) (shwap.RowNamespaceData, error) Shares(ctx context.Context) ([]libshare.Share, error) }
Accessor is an interface for accessing extended data square data.
func WithValidation ¶ added in v0.20.2
type AccessorStreamer ¶ added in v0.20.2
AccessorStreamer is an interface that groups Accessor and Streamer interfaces.
func AccessorAndStreamer ¶ added in v0.20.2
func AccessorAndStreamer(a Accessor, s Streamer) AccessorStreamer
func WithClosedOnce ¶ added in v0.20.2
func WithClosedOnce(f AccessorStreamer) AccessorStreamer
func WithProofsCache ¶ added in v0.20.2
func WithProofsCache(ac AccessorStreamer) AccessorStreamer
WithProofsCache creates a new eds accessor with caching of proofs for rows and columns. It is used to speed up the process of building proofs for rows and columns, reducing the number of reads from the underlying accessor.
type AxisHalf ¶ added in v0.20.2
type AxisHalf struct { // IsParity indicates whether the half is parity or data. IsParity bool }
AxisHalf represents a half of data for a row or column in the EDS.
type Retriever ¶
type Retriever struct {
// contains filtered or unexported fields
}
Retriever retrieves rsmt2d.ExtendedDataSquares from the IPLD network. Instead of requesting data 'share by share' it requests data by quadrants minimizing bandwidth usage in the happy cases.
---- ---- | 0 | 1 | ---- ---- | 2 | 3 | ---- ----
Retriever randomly picks one of the data square quadrants and tries to request them one by one until it is able to reconstruct the whole square.
func NewRetriever ¶
func NewRetriever(bServ blockservice.BlockService) *Retriever
NewRetriever creates a new instance of the Retriever over IPLD BlockService and rmst2d.Codec
func (*Retriever) Retrieve ¶
func (r *Retriever) Retrieve(ctx context.Context, roots *share.AxisRoots) (*rsmt2d.ExtendedDataSquare, error)
Retrieve retrieves all the data committed to DataAvailabilityHeader.
If not available locally, it aims to request from the network only one quadrant (1/4) of the data square and reconstructs the other three quadrants (3/4). If the requested quadrant is not available within RetrieveQuadrantTimeout, it starts requesting another quadrant until either the data is reconstructed, context is canceled or ErrByzantine is generated.
type Rsmt2D ¶ added in v0.20.2
type Rsmt2D struct {
*rsmt2d.ExtendedDataSquare
}
Rsmt2D is a rsmt2d based in-memory implementation of Accessor.
func ReadAccessor ¶ added in v0.20.2
ReadAccessor reads up EDS out of the io.Reader until io.EOF and provides.
func Rsmt2DFromShares ¶ added in v0.20.2
Rsmt2DFromShares constructs an Extended Data Square from shares.
func (*Rsmt2D) AxisHalf ¶ added in v0.20.2
AxisHalf returns Shares for the first half of the axis of the given type and index.
func (*Rsmt2D) HalfRow ¶ added in v0.20.2
HalfRow constructs a new shwap.Row from an Extended Data Square based on the specified index and side.
func (*Rsmt2D) RowNamespaceData ¶ added in v0.20.2
func (eds *Rsmt2D) RowNamespaceData( _ context.Context, namespace libshare.Namespace, rowIdx int, ) (shwap.RowNamespaceData, error)
RowNamespaceData returns data for the given namespace and row index.
func (*Rsmt2D) Sample ¶ added in v0.20.2
Sample returns share and corresponding proof for row and column indices.
func (*Rsmt2D) SampleForProofAxis ¶ added in v0.20.2
func (eds *Rsmt2D) SampleForProofAxis( idx shwap.SampleCoords, proofType rsmt2d.Axis, ) (shwap.Sample, error)
SampleForProofAxis samples a share from an Extended Data Square based on the provided row and column indices and proof axis. It returns a sample with the share and proof.
type ShareReader ¶ added in v0.20.2
type ShareReader struct {
// contains filtered or unexported fields
}
ShareReader implement io.Reader over general function that gets shares by their respective Row and Col coordinates. It enables share streaming over arbitrary storages.
func NewShareReader ¶ added in v0.20.2
func NewShareReader(odsSize int, getShare func(rowIdx, colIdx int) (libshare.Share, error)) *ShareReader
NewShareReader constructs a new ShareGetter from underlying ODS size and general share getting function.