v0.2300.9 Latest Latest

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 12 Imported by: 1



Package transaction implements the runtime transaction semantics.



This section is empty.


View Source
var (
	// ErrNotFound is the error returned when a transaction with the given hash
	// cannot be found.
	ErrNotFound = errors.New("transaction: not found")
View Source
var TagBlockTxHash = hash.Hash([32]byte{})

TagBlockTxHash is the hash used for block emitted tags not tied to a specific transaction.


func ValidateIOWriteLog added in v0.2100.0

func ValidateIOWriteLog(writeLog writelog.WriteLog, maxBatchSize, maxBatchSizeBytes uint64) error

ValidateIOWriteLog validates the writelog for IO storage.


type CoarsenedKey

type CoarsenedKey []byte

CoarsenedKey is a coarsened key prefix that represents any key that starts with this prefix.

type CoarsenedSet

type CoarsenedSet []CoarsenedKey

CoarsenedSet is a set of coarsened keys.

func (CoarsenedSet) Equal

func (s CoarsenedSet) Equal(other CoarsenedSet) bool

Equal checks whether the coarsened set is equal to another.

type RawBatch

type RawBatch [][]byte

RawBatch is a list of opaque bytes.

type ReadWriteSet

type ReadWriteSet struct {
	// Granularity is the size of the key prefixes (in bytes) used for
	// coarsening the keys.
	Granularity uint16 `json:"granularity"`
	// ReadSet is the read set.
	ReadSet CoarsenedSet `json:"read_set"`
	// WriteSet is the write set.
	WriteSet CoarsenedSet `json:"write_set"`

ReadWriteSet is a read/write set.

func (ReadWriteSet) Equal

func (rw ReadWriteSet) Equal(other *ReadWriteSet) bool

Equal checks whether the read/write set is equal to another.

func (ReadWriteSet) Size

func (rw ReadWriteSet) Size() uint64

Size returns the size (in bytes) of the read/write set.

type Tag

type Tag struct {
	// Key is the tag key.
	Key []byte
	// Value is the tag value.
	Value []byte
	// TxHash is the hash of the transaction that emitted the tag.
	TxHash hash.Hash

Tag is a key/value pair of arbitrary byte blobs with runtime-dependent semantics which can be indexed to allow easier lookup of transactions on runtime clients.

type Tags

type Tags []Tag

Tags is a set of tags.

type Transaction

type Transaction struct {
	// Input is the transaction input.
	Input []byte
	// Output is the transaction output (if available).
	Output []byte
	// BatchOrder is the transaction order within the batch.
	// This is only relevant within the committee that is processing the batch
	// and should be ignored once transactions from multiple committees are
	// merged together.
	BatchOrder uint32

Transaction is an executed (or executing) transaction.

This is the transaction representation used for convenience as a collection of all transaction artifacts. It is never serialized directly.

func (Transaction) Equal

func (t Transaction) Equal(other *Transaction) bool

Equal checks whether the transaction is equal to another.

func (Transaction) Hash

func (t Transaction) Hash() hash.Hash

Hash returns the hash of the transaction.

This requires the input artifact to be available.

type Tree

type Tree struct {
	// contains filtered or unexported fields

Tree is a Merkle tree containing transaction artifacts.

func NewTree

func NewTree(rs syncer.ReadSyncer, ioRoot node.Root) *Tree

NewTree creates a new transaction artifacts tree.

func (*Tree) AddTransaction

func (t *Tree) AddTransaction(ctx context.Context, tx Transaction, tags Tags) error

AddTransaction adds a new set of transaction artifacts for a given transaction, optionally with emitted transaction tags.

At least the Input artifact must be specified as that defines the hash of the transaction.

func (*Tree) Close

func (t *Tree) Close()

Close releases resources associated with this transaction artifact tree.

func (*Tree) Commit

func (t *Tree) Commit(ctx context.Context) (writelog.WriteLog, hash.Hash, error)

Commit commits the updates to the underlying Merkle tree and returns the write log and root hash.

func (*Tree) GetInputBatch

func (t *Tree) GetInputBatch(ctx context.Context, maxBatchSize, maxBatchSizeBytes uint64) (RawBatch, error)

GetInputBatch returns a batch of transaction input artifacts in batch order.

func (*Tree) GetTags

func (t *Tree) GetTags(ctx context.Context) (Tags, error)

GetTags retrieves all tags emitted in this tree.

func (*Tree) GetTransaction

func (t *Tree) GetTransaction(ctx context.Context, txHash hash.Hash) (*Transaction, error)

GetTransaction looks up a transaction by its hash and retrieves all of its artifacts.

func (*Tree) GetTransactionMultiple

func (t *Tree) GetTransactionMultiple(ctx context.Context, txHashes []hash.Hash) (map[hash.Hash]*Transaction, error)

GetTransactionMultiple looks up multiple transactions by their hashes at once and retrieves all of their artifacts.

The function behaves identically to multiple GetTransaction calls, but is more efficient as it performs prefetching to get all the requested transactions in one round trip.

func (*Tree) GetTransactions

func (t *Tree) GetTransactions(ctx context.Context) ([]*Transaction, error)

GetTransactions returns a list of all transaction artifacts in batch order.

Jump to

Keyboard shortcuts

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