Skip to content

Commit

Permalink
feat(share/eds): trace read from stream and trace extend
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay committed Feb 17, 2025
1 parent f58a189 commit 6297a34
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion share/eds/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@ import (

libshare "github.com/celestiaorg/go-square/v2/share"

"github.com/celestiaorg/celestia-node/libs/utils"
"github.com/celestiaorg/celestia-node/share"
)

// ReadAccessor reads up EDS out of the io.Reader until io.EOF and provides.
func ReadAccessor(ctx context.Context, reader io.Reader, root *share.AxisRoots) (*Rsmt2D, error) {
odsSize := len(root.RowRoots) / 2
var (
odsSize = len(root.RowRoots) / 2
err error
)

ctx, span := tracer.Start(ctx, "read-shares")
shares, err := ReadShares(reader, libshare.ShareSize, odsSize)
if err != nil {
return nil, fmt.Errorf("failed to read eds from ods bytes: %w", err)
}
utils.SetStatusAndEnd(span, err)

ctx, span = tracer.Start(ctx, "extend-shares")
// verify that the EDS hash matches the expected hash
rsmt2d, err := Rsmt2DFromShares(shares, odsSize)
if err != nil {
return nil, fmt.Errorf("failed to create rsmt2d from shares: %w", err)
}
utils.SetStatusAndEnd(span, err)

datahash, err := rsmt2d.DataHash(ctx)
if err != nil {
return nil, fmt.Errorf("failed to calculate data hash: %w", err)
Expand Down

0 comments on commit 6297a34

Please sign in to comment.