blob

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 12

Documentation

Overview

Package blob provides types and functions for working with blobs, blob transactions, and index wrapper transactions.

Index

Constants

View Source
const MaxShareVersion = 127

MaxShareVersion is the maximum value a share version can be. See: [shares.MaxShareVersion].

View Source
const ProtoBlobTxTypeID = "BLOB"

ProtoBlobTxTypeID is included in each encoded BlobTx to help prevent decoding binaries that are not actually BlobTxs.

View Source
const ProtoIndexWrapperTypeID = "INDX"

ProtoIndexWrapperTypeID is included in each encoded IndexWrapper to help prevent decoding binaries that are not actually IndexWrappers.

Variables

View Source
var File_blob_blob_proto protoreflect.FileDescriptor
View Source
var SupportedBlobNamespaceVersions = []uint8{namespace.NamespaceVersionZero}

SupportedBlobNamespaceVersions is a list of namespace versions that can be specified by a user for blobs.

Functions

func MarshalBlobTx

func MarshalBlobTx(tx []byte, blobs ...*Blob) ([]byte, error)

MarshalBlobTx creates a BlobTx using a normal transaction and some number of blobs.

NOTE: Any checks on the blobs or the transaction must be performed in the application

func MarshalIndexWrapper

func MarshalIndexWrapper(tx []byte, shareIndexes ...uint32) ([]byte, error)

MarshalIndexWrapper creates a wrapped Tx that includes the original transaction and the share index of the start of its blob.

NOTE: must be unwrapped to be a viable sdk.Tx

func Sort

func Sort(blobs []*Blob)

Sort sorts the blobs by their namespace.

Types

type Blob

type Blob struct {
	NamespaceId      []byte `protobuf:"bytes,1,opt,name=namespace_id,json=namespaceId,proto3" json:"namespace_id,omitempty"`
	Data             []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	ShareVersion     uint32 `protobuf:"varint,3,opt,name=share_version,json=shareVersion,proto3" json:"share_version,omitempty"`
	NamespaceVersion uint32 `protobuf:"varint,4,opt,name=namespace_version,json=namespaceVersion,proto3" json:"namespace_version,omitempty"`
	// contains filtered or unexported fields
}

Blob (named after binary large object) is a chunk of data submitted by a user to be published to the Celestia blockchain. The data of a Blob is published to a namespace and is encoded into shares based on the format specified by share_version.

func New

func New(ns namespace.Namespace, blob []byte, shareVersion uint8) *Blob

New creates a new coretypes.Blob from the provided data after performing basic stateless checks over it.

func (*Blob) Descriptor deprecated

func (*Blob) Descriptor() ([]byte, []int)

Deprecated: Use Blob.ProtoReflect.Descriptor instead.

func (*Blob) GetData

func (x *Blob) GetData() []byte

func (*Blob) GetNamespaceId

func (x *Blob) GetNamespaceId() []byte

func (*Blob) GetNamespaceVersion

func (x *Blob) GetNamespaceVersion() uint32

func (*Blob) GetShareVersion

func (x *Blob) GetShareVersion() uint32

func (*Blob) Namespace

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

Namespace returns the namespace of the blob

func (*Blob) ProtoMessage

func (*Blob) ProtoMessage()

func (*Blob) ProtoReflect

func (x *Blob) ProtoReflect() protoreflect.Message

func (*Blob) Reset

func (x *Blob) Reset()

func (*Blob) String

func (x *Blob) String() string

func (*Blob) Validate

func (b *Blob) Validate() error

Validate runs a stateless validity check on the form of the struct.

type BlobTx

type BlobTx struct {
	Tx     []byte  `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"`
	Blobs  []*Blob `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty"`
	TypeId string  `protobuf:"bytes,3,opt,name=type_id,json=typeId,proto3" json:"type_id,omitempty"`
	// contains filtered or unexported fields
}

BlobTx wraps an encoded sdk.Tx with a second field to contain blobs of data. The raw bytes of the blobs are not signed over, instead we verify each blob using the relevant MsgPayForBlobs that is signed over in the encoded sdk.Tx.

func UnmarshalBlobTx

func UnmarshalBlobTx(tx []byte) (*BlobTx, bool)

UnmarshalBlobTx attempts to unmarshal a transaction into blob transaction. If an error is thrown, false is returned.

func (*BlobTx) Descriptor deprecated

func (*BlobTx) Descriptor() ([]byte, []int)

Deprecated: Use BlobTx.ProtoReflect.Descriptor instead.

func (*BlobTx) GetBlobs

func (x *BlobTx) GetBlobs() []*Blob

func (*BlobTx) GetTx

func (x *BlobTx) GetTx() []byte

func (*BlobTx) GetTypeId

func (x *BlobTx) GetTypeId() string

func (*BlobTx) ProtoMessage

func (*BlobTx) ProtoMessage()

func (*BlobTx) ProtoReflect

func (x *BlobTx) ProtoReflect() protoreflect.Message

func (*BlobTx) Reset

func (x *BlobTx) Reset()

func (*BlobTx) String

func (x *BlobTx) String() string

type IndexWrapper

type IndexWrapper struct {
	Tx           []byte   `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"`
	ShareIndexes []uint32 `protobuf:"varint,2,rep,packed,name=share_indexes,json=shareIndexes,proto3" json:"share_indexes,omitempty"`
	TypeId       string   `protobuf:"bytes,3,opt,name=type_id,json=typeId,proto3" json:"type_id,omitempty"`
	// contains filtered or unexported fields
}

IndexWrapper adds index metadata to a transaction. This is used to track transactions that pay for blobs, and where the blobs start in the square.

func UnmarshalIndexWrapper

func UnmarshalIndexWrapper(tx []byte) (*IndexWrapper, bool)

UnmarshalIndexWrapper attempts to unmarshal the provided transaction into an IndexWrapper transaction. It returns true if the provided transaction is an IndexWrapper transaction. An IndexWrapper transaction is a transaction that contains a MsgPayForBlob that has been wrapped with a share index.

NOTE: protobuf sometimes does not throw an error if the transaction passed is not a IndexWrapper, since the protobuf definition for MsgPayForBlob is kept in the app, we cannot perform further checks without creating an import cycle.

func (*IndexWrapper) Descriptor deprecated

func (*IndexWrapper) Descriptor() ([]byte, []int)

Deprecated: Use IndexWrapper.ProtoReflect.Descriptor instead.

func (*IndexWrapper) GetShareIndexes

func (x *IndexWrapper) GetShareIndexes() []uint32

func (*IndexWrapper) GetTx

func (x *IndexWrapper) GetTx() []byte

func (*IndexWrapper) GetTypeId

func (x *IndexWrapper) GetTypeId() string

func (*IndexWrapper) ProtoMessage

func (*IndexWrapper) ProtoMessage()

func (*IndexWrapper) ProtoReflect

func (x *IndexWrapper) ProtoReflect() protoreflect.Message

func (*IndexWrapper) Reset

func (x *IndexWrapper) Reset()

func (*IndexWrapper) String

func (x *IndexWrapper) String() string

Jump to

Keyboard shortcuts

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