Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptySquare = errors.New("share: importing empty data")
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 ReadEDS ¶ added in v0.5.0
ReadEDS reads the first EDS quadrant (1/4) from an io.Reader CAR file. Only the first quadrant will be read, which represents the original data. The returned EDS is guaranteed to be full and valid against the DataRoot, otherwise ReadEDS errors.
func WriteEDS ¶ added in v0.5.0
WriteEDS writes the entire EDS into the given io.Writer as CARv1 file. This includes all shares in quadrant order, followed by all inner nodes of the NMT tree. Order: [ Carv1Header | Q1 | Q2 | Q3 | Q4 | inner nodes ] For more information about the header: https://ipld.io/specs/transport/car/carv1/#header
Types ¶
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, dah *da.DataAvailabilityHeader) (*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.