-
Notifications
You must be signed in to change notification settings - Fork 884
/
availability.go
37 lines (30 loc) · 1.08 KB
/
availability.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package share
import (
"context"
"errors"
"github.com/celestiaorg/celestia-app/pkg/da"
"github.com/celestiaorg/rsmt2d"
"github.com/celestiaorg/celestia-node/header"
)
// ErrNotAvailable is returned whenever DA sampling fails.
var ErrNotAvailable = errors.New("share: data not available")
// Root represents root commitment to multiple Shares.
// In practice, it is a commitment to all the Data in a square.
type Root = da.DataAvailabilityHeader
// NewRoot generates Root(DataAvailabilityHeader) using the
// provided extended data square.
func NewRoot(eds *rsmt2d.ExtendedDataSquare) (*Root, error) {
dah, err := da.NewDataAvailabilityHeader(eds)
if err != nil {
return nil, err
}
return &dah, nil
}
// Availability defines interface for validation of Shares' availability.
//
//go:generate mockgen -destination=availability/mocks/availability.go -package=mocks . Availability
type Availability interface {
// SharesAvailable subjectively validates if Shares committed to the given Root are available on
// the Network.
SharesAvailable(context.Context, *header.ExtendedHeader) error
}