Documentation
¶
Overview ¶
Package square implements the logic to construct the original data square based on a list of transactions.
Index ¶
- func BlobShareRange(txs [][]byte, txIndex, blobIndex, maxSquareSize, subtreeRootThreshold int) (share.Range, error)
- func IsPowerOfTwo[I constraints.Integer](input I) bool
- func RoundUpPowerOfTwo[I constraints.Integer](input I) I
- func Size(length int) int
- func TxShareRange(txs [][]byte, txIndex, maxSquareSize, subtreeRootThreshold int) (share.Range, error)
- type Builder
- func (b *Builder) AppendBlobTx(blobTx *tx.BlobTx) bool
- func (b *Builder) AppendTx(tx []byte) bool
- func (b *Builder) BlobShareLength(pfbIndex, blobIndex int) (int, error)
- func (b *Builder) CurrentSize() int
- func (b *Builder) Export() (Square, error)
- func (b *Builder) FindBlobStartingIndex(pfbIndex, blobIndex int) (int, error)
- func (b *Builder) FindTxShareRange(txIndex int) (share.Range, error)
- func (b *Builder) GetWrappedPFB(txIndex int) (*v2.IndexWrapper, error)
- func (b *Builder) IsEmpty() bool
- func (b *Builder) NumPFBs() int
- func (b *Builder) NumTxs() int
- func (b *Builder) RevertLastBlobTx() error
- func (b *Builder) RevertLastTx() error
- func (b *Builder) SubtreeRootThreshold() int
- type Element
- type PFBDecoder
- type Square
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlobShareRange ¶
func BlobShareRange(txs [][]byte, txIndex, blobIndex, maxSquareSize, subtreeRootThreshold int) (share.Range, error)
BlobShareRange returns the range of share indexes that the blob, identified by txIndex and blobIndex, occupies. The range is end exclusive.
func IsPowerOfTwo ¶
func IsPowerOfTwo[I constraints.Integer](input I) bool
IsPowerOfTwo returns true if input is a power of two.
func RoundUpPowerOfTwo ¶
func RoundUpPowerOfTwo[I constraints.Integer](input I) I
RoundUpPowerOfTwo returns the next power of two greater than or equal to input.
Types ¶
type Builder ¶
type Builder struct { // here we keep track of the pending data to go in a square Txs [][]byte Pfbs []*v2.IndexWrapper Blobs []*Element // for compact shares we use a counter to track the amount of shares needed TxCounter *share.CompactShareCounter PfbCounter *share.CompactShareCounter // contains filtered or unexported fields }
func NewBuilder ¶
func (*Builder) AppendBlobTx ¶
AppendBlobTx attempts to allocate the blob transaction to the square. It returns false if there is not enough space in the square to fit the transaction.
func (*Builder) AppendTx ¶
AppendTx attempts to allocate the transaction to the square. It returns false if there is not enough space in the square to fit the transaction.
func (*Builder) BlobShareLength ¶
BlobShareLength returns the amount of shares a blob takes up in the square. It takes the index of the pfb in the tx set and the index of the blob within the PFB. TODO: we could look in to creating a map to avoid O(n) lookup when we expect large numbers of blobs
func (*Builder) CurrentSize ¶
func (*Builder) FindBlobStartingIndex ¶
FindBlobStartingIndex returns the starting share index of the blob in the square. It takes the index of the pfb in the tx set and the index of the blob within the PFB.
func (*Builder) FindTxShareRange ¶
FindTxShareRange returns the range of shares occupied by the tx at txIndex. The indexes are both inclusive.
func (*Builder) GetWrappedPFB ¶
func (b *Builder) GetWrappedPFB(txIndex int) (*v2.IndexWrapper, error)
func (*Builder) RevertLastBlobTx ¶
RevertLastBlobTx reverts the last blob transaction that was appended to the builder. It returns an error if there are no blob transactions to revert or if this method has been called consecutively without adding a tx in between calls.
func (*Builder) RevertLastTx ¶
RevertLastTx reverts the last transaction that was appended to the builder. It returns an error if there are no transactions to revert or if this method has been called consecutively without adding a tx in between calls.
func (*Builder) SubtreeRootThreshold ¶
type PFBDecoder ¶
type Square ¶
Square is a 2D square of shares with symmetrical sides that are always a power of 2.
func Build ¶
Build takes an arbitrary long list of (prioritized) transactions and builds a square that is never greater than maxSquareSize. It also returns the ordered list of transactions that are present in the square and which have all PFBs trailing regular transactions. Note, this function does not check the underlying validity of the transactions. Errors should not occur and would reflect a violation in an invariant.
func Construct ¶
Construct takes the exact list of ordered transactions and constructs a square, validating that
- all blobTxs are ordered after non-blob transactions
- the transactions don't collectively exceed the maxSquareSize.
Note that this function does not check the underlying validity of the transactions.
func EmptySquare ¶
func EmptySquare() Square
EmptySquare returns a 1x1 square with a single tail padding share
func WriteSquare ¶
func WriteSquare( txWriter, pfbWriter *share.CompactShareSplitter, blobWriter *share.SparseShareSplitter, nonReservedStart, squareSize int, ) (Square, error)
func (Square) ToBytes ¶
ToBytes returns all the shares in the square flattened into a single byte slice.
func (Square) WrappedPFBs ¶
WrappedPFBs returns the wrapped PFBs in a square
Directories
¶
Path | Synopsis |
---|---|
Package inclusion contains functions to generate the blob share commitment from a given blob.
|
Package inclusion contains functions to generate the blob share commitment from a given blob. |
internal
|
|
proto
|
|
Package share is an encoding and decoding protocol that takes blobs, a struct containing arbitrary data based on a namespace and coverts them into a slice of shares, bytes 512 in length.
|
Package share is an encoding and decoding protocol that takes blobs, a struct containing arbitrary data based on a namespace and coverts them into a slice of shares, bytes 512 in length. |