blob

package
v0.11.0-rc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2023 License: Apache-2.0 Imports: 19 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlobNotFound = errors.New("blob: not found")
	ErrInvalidProof = errors.New("blob: invalid proof")
)

Functions

func BlobsToShares

func BlobsToShares(blobs ...*Blob) ([]share.Share, error)

BlobsToShares accepts blobs and convert them to the Shares.

Types

type Blob

type Blob struct {
	types.Blob `json:"blob"`

	Commitment Commitment `json:"commitment"`
	// contains filtered or unexported fields
}

Blob represents any application-specific binary data that anyone can submit to Celestia.

func NewBlob

func NewBlob(shareVersion uint8, namespace share.Namespace, data []byte) (*Blob, error)

NewBlob constructs a new blob from the provided Namespace, data and share version.

func NewBlobV0

func NewBlobV0(namespace share.Namespace, data []byte) (*Blob, error)

NewBlobV0 constructs a new blob from the provided Namespace and data. The blob will be formatted as v0 shares.

func SharesToBlobs

func SharesToBlobs(rawShares []share.Share) ([]*Blob, error)

SharesToBlobs takes raw shares and converts them to the blobs.

func (*Blob) MarshalJSON

func (b *Blob) MarshalJSON() ([]byte, error)

func (*Blob) Namespace

func (b *Blob) Namespace() share.Namespace

Namespace returns blob's namespace.

func (*Blob) UnmarshalJSON

func (b *Blob) UnmarshalJSON(data []byte) error

type Commitment

type Commitment []byte

Commitment is a Merkle Root of the subtree built from shares of the Blob. It is computed by splitting the blob into shares and building the Merkle subtree to be included after Submit.

func (Commitment) Equal

func (com Commitment) Equal(c Commitment) bool

Equal ensures that commitments are the same

func (Commitment) String

func (com Commitment) String() string

type Proof

type Proof []*nmt.Proof

Proof is a collection of nmt.Proofs that verifies the inclusion of the data.

func (Proof) Len

func (p Proof) Len() int

func (*Proof) MarshalJSON added in v0.13.0

func (p *Proof) MarshalJSON() ([]byte, error)

func (*Proof) UnmarshalJSON added in v0.13.0

func (p *Proof) UnmarshalJSON(data []byte) error

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(
	submitter Submitter,
	getter share.Getter,
	headerGetter func(context.Context, uint64) (*header.ExtendedHeader, error),
) *Service

func (*Service) Get

func (s *Service) Get(ctx context.Context, height uint64, ns share.Namespace, commitment Commitment) (*Blob, error)

Get retrieves all the blobs for given namespaces at the given height by commitment.

func (*Service) GetAll

func (s *Service) GetAll(ctx context.Context, height uint64, namespaces []share.Namespace) ([]*Blob, error)

GetAll returns all blobs under the given namespaces at the given height. GetAll can return blobs and an error in case if some requests failed.

func (*Service) GetProof

func (s *Service) GetProof(
	ctx context.Context,
	height uint64,
	namespace share.Namespace,
	commitment Commitment,
) (*Proof, error)

GetProof retrieves all blobs in the given namespaces at the given height by commitment and returns their Proof.

func (*Service) Included

func (s *Service) Included(
	ctx context.Context,
	height uint64,
	namespace share.Namespace,
	proof *Proof,
	com Commitment,
) (bool, error)

Included verifies that the blob was included in a specific height. To ensure that blob was included in a specific height, we need: 1. verify the provided commitment by recomputing it; 2. verify the provided Proof against subtree roots that were used in 1.;

func (*Service) Submit

func (s *Service) Submit(ctx context.Context, blobs []*Blob) (uint64, error)

Submit sends PFB transaction and reports the height in which it was included. Allows sending multiple Blobs atomically synchronously. Uses default wallet registered on the Node.

type Submitter

type Submitter interface {
	SubmitPayForBlob(ctx context.Context, fee math.Int, gasLim uint64, blobs []*Blob) (*types.TxResponse, error)
}

Submitter is an interface that allows submitting blobs to the celestia-core. It is used to avoid a circular dependency between the blob and the state package, since the state package needs the blob.Blob type for this signature.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL