transaction

package
v0.2103.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package transaction implements the runtime transaction semantics.

Index

Constants

View Source
const (
	// WeightConsensusMessages is the consensus messages weight key.
	WeightConsensusMessages = Weight("consensus_messages")
	// WeightSizeBytes is the transaction byte size weight key.
	WeightSizeBytes = Weight("size_bytes")
	// WeightCount is the transaction count weight key.
	WeightCount = Weight("count")
)

Variables

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.

Functions

func ValidateIOWriteLog added in v0.2100.0

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

ValidateIOWriteLog validates the writelog for IO storage.

Types

type CheckedTransaction added in v0.2102.0

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

CheckedTransaction is a checked transaction to be scheduled.

func NewCheckedTransaction added in v0.2102.0

func NewCheckedTransaction(tx []byte, priority uint64, weights map[Weight]uint64) *CheckedTransaction

NewCheckedTransaction creates a new CheckedTransactions from the provided bytes, priority and weights.

func RawCheckedTransaction added in v0.2102.0

func RawCheckedTransaction(raw []byte) *CheckedTransaction

RawCheckedTransactions creates a new CheckedTransactions from the raw bytes.

func (*CheckedTransaction) Hash added in v0.2102.0

func (t *CheckedTransaction) Hash() hash.Hash

Hash returns the hash of the transaction binary data.

func (*CheckedTransaction) Priority added in v0.2102.0

func (t *CheckedTransaction) Priority() uint64

Priority returns the transaction priority.

func (*CheckedTransaction) Raw added in v0.2102.0

func (t *CheckedTransaction) Raw() []byte

Raw returns the raw transaction data.

func (*CheckedTransaction) Size added in v0.2102.0

func (t *CheckedTransaction) Size() uint64

Size returns the size (in bytes) of the raw transaction data.

func (*CheckedTransaction) String added in v0.2102.0

func (t *CheckedTransaction) String() string

String returns string representation of the raw transaction data.

func (*CheckedTransaction) Weight added in v0.2102.0

func (t *CheckedTransaction) Weight(w Weight) uint64

Weight returns the specific transaction weight.

func (*CheckedTransaction) Weights added in v0.2102.0

func (t *CheckedTransaction) Weights() map[Weight]uint64

Weights returns all transaction transaction weights.

To avoid unnecessary allocations the internal weights map is returned. The caller should not modify the map.

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 the tree in a stable order (transactions are ordered by their hash).

type Weight added in v0.2102.0

type Weight string

Weight is the transaction weight type.

func (Weight) IsCustom added in v0.2102.0

func (w Weight) IsCustom() bool

IsCustom returns if the weight is a custom runtime weight.

Jump to

Keyboard shortcuts

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