Documentation
¶
Index ¶
- Constants
- Variables
- func EqualEDS(a *rsmt2d.ExtendedDataSquare, b *rsmt2d.ExtendedDataSquare) bool
- func ExtractODSShares(eds *rsmt2d.ExtendedDataSquare) [][]byte
- func GetLeaf(ctx context.Context, dag ipld.NodeGetter, root cid.Cid, leaf, total int) (ipld.Node, error)
- func GetLeafData(ctx context.Context, rootCid cid.Cid, leafIndex uint32, totalLeafs uint32, ...) ([]byte, error)
- func GetLeavesByNamespace(ctx context.Context, dag ipld.NodeGetter, root cid.Cid, nID namespace.ID) (out []ipld.Node, err error)
- func PutData(ctx context.Context, shares [][]byte, adder ipld.NodeAdder) (*rsmt2d.ExtendedDataSquare, error)
- func RandEDS(t *testing.T, size int) *rsmt2d.ExtendedDataSquare
- func RandNamespacedCID(t *testing.T) cid.Cid
- func RetrieveData(ctx context.Context, dah *da.DataAvailabilityHeader, dag ipld.NodeGetter, ...) (*rsmt2d.ExtendedDataSquare, error)
- type NamespacedShare
- type NamespacedShares
- type NmtNodeAdder
- type Share
Constants ¶
const ( // MaxSquareSize is currently the maximum size supported for unerasured data in rsmt2d.ExtendedDataSquare. MaxSquareSize = 128 // NamespaceSize is a system wide size for NMT namespaces. // TODO(Wondertan): Should be part of IPLD/NMT plugin NamespaceSize = 8 )
const BatchSize = 1
BatchSize defines an amount of IPLD Nodes to be buffered and written at once. This configuration is very database backend specific and the current default(128) is not optimized for the version of Badger we use. We set it to one to avoid test flakiness, as some tests may read for data that was not written yet. TODO(@Wondertan): Find out the perfect value for Badger(e.g. ask PL folks) or migrate to go-car IPLD
storage(preferred).
Variables ¶
var ErrNotFoundInRange = fmt.Errorf("namespaceID not found in range")
var ErrRetrieveTimeout = errors.New("retrieve data timeout")
Functions ¶
func EqualEDS ¶
func EqualEDS(a *rsmt2d.ExtendedDataSquare, b *rsmt2d.ExtendedDataSquare) bool
TODO(Wondertan): Move to rsmt2d TODO(Wondertan): Propose use of int by default instead of uint for the sake convenience and Golang practices
func ExtractODSShares ¶
func ExtractODSShares(eds *rsmt2d.ExtendedDataSquare) [][]byte
ExtractODSShares returns the original shares of the given ExtendedDataSquare. This is a helper function for circumstances where PutData must be used after the EDS has already been generated.
func GetLeaf ¶
func GetLeaf(ctx context.Context, dag ipld.NodeGetter, root cid.Cid, leaf, total int) (ipld.Node, error)
GetLeaf fetches and returns the raw leaf. It walks down the IPLD NMT tree until it finds the requested one.
func GetLeafData ¶
func GetLeafData( ctx context.Context, rootCid cid.Cid, leafIndex uint32, totalLeafs uint32, dag ipld.NodeGetter, ) ([]byte, error)
GetLeafData fetches and returns the data for leaf leafIndex of root rootCid. It stops and returns an error if the provided context is canceled before finishing
func GetLeavesByNamespace ¶
func GetLeavesByNamespace( ctx context.Context, dag ipld.NodeGetter, root cid.Cid, nID namespace.ID, ) (out []ipld.Node, err error)
GetLeavesByNamespace returns all the shares from the given DataAvailabilityHeader root with the given namespace.ID.
func PutData ¶
func PutData(ctx context.Context, shares [][]byte, adder ipld.NodeAdder) (*rsmt2d.ExtendedDataSquare, error)
PutData posts erasured block data to IPFS using the provided ipld.NodeAdder.
func RandNamespacedCID ¶
TODO(Wondertan): Move to NMT plugin
func RetrieveData ¶
func RetrieveData( ctx context.Context, dah *da.DataAvailabilityHeader, dag ipld.NodeGetter, codec rsmt2d.Codec, ) (*rsmt2d.ExtendedDataSquare, error)
RetrieveData asynchronously fetches block data using the minimum number of requests to IPFS. It fails if one of the random samples sampled is not available.
Types ¶
type NamespacedShare ¶
type NamespacedShare struct {}
TODO(Wondertan): Consider using alias to namespace.PrefixedData instead NamespacedShare extends a Share with the corresponding namespace.
func (NamespacedShare) Data ¶
func (n NamespacedShare) Data() []byte
func (NamespacedShare) NamespaceID ¶
func (n NamespacedShare) NamespaceID() namespace.ID
type NamespacedShares ¶
type NamespacedShares []NamespacedShare
NamespacedShares is just a list of NamespacedShare elements. It can be used to extract the raw shares.
func RandNamespacedShares ¶
func RandNamespacedShares(t *testing.T, total int) NamespacedShares
func (NamespacedShares) Raw ¶
func (ns NamespacedShares) Raw() [][]byte
Raw returns the raw shares that can be fed into the erasure coding library (e.g. rsmt2d).
type NmtNodeAdder ¶
type NmtNodeAdder struct {
// contains filtered or unexported fields
}
NmtNodeAdder adds ipld.Nodes to the underlying ipld.Batch if it is inserted into an nmt tree
func NewNmtNodeAdder ¶
func NewNmtNodeAdder(ctx context.Context, add ipld.NodeAdder) *NmtNodeAdder
NewNmtNodeAdder returns a new NmtNodeAdder with the provided context and batch. Note that the context provided should have a timeout It is not thread-safe.
func (*NmtNodeAdder) Commit ¶
func (n *NmtNodeAdder) Commit() error
Commit checks for errors happened during Visit and if absent commits data to inner Batch.
func (*NmtNodeAdder) NodeAdder ¶
func (n *NmtNodeAdder) NodeAdder() ipld.NodeAdder
Adder return the ipld.NodeAdder originally provided to the NmtNodeAdder.
func (*NmtNodeAdder) Visit ¶
func (n *NmtNodeAdder) Visit(hash []byte, children ...[]byte)
Visit is a NodeVisitor that can be used during the creation of a new NMT to create and add ipld.Nodes to the Batch while computing the root of the NMT.