Documentation
¶
Overview ¶
Package transaction implements the runtime transaction semantics.
Index ¶
- Variables
- func ValidateIOWriteLog(writeLog writelog.WriteLog, maxBatchSize, maxBatchSizeBytes uint64) error
- type CoarsenedKey
- type CoarsenedSet
- type RawBatch
- type ReadWriteSet
- type Tag
- type Tags
- type Transaction
- type Tree
- func (t *Tree) AddTransaction(ctx context.Context, tx Transaction, tags Tags) error
- func (t *Tree) Close()
- func (t *Tree) Commit(ctx context.Context) (writelog.WriteLog, hash.Hash, error)
- func (t *Tree) GetInputBatch(ctx context.Context, maxBatchSize, maxBatchSizeBytes uint64) (RawBatch, error)
- func (t *Tree) GetTags(ctx context.Context) (Tags, error)
- func (t *Tree) GetTransaction(ctx context.Context, txHash hash.Hash) (*Transaction, error)
- func (t *Tree) GetTransactionMultiple(ctx context.Context, txHashes []hash.Hash) (map[hash.Hash]*Transaction, error)
- func (t *Tree) GetTransactions(ctx context.Context) ([]*Transaction, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is the error returned when a transaction with the given hash // cannot be found. ErrNotFound = errors.New("transaction: not found") )
var TagBlockTxHash = hash.Hash([32]byte{})
TagBlockTxHash is the hash used for block emitted tags not tied to a specific transaction.
Functions ¶
Types ¶
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 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 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 ¶
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 ¶
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) GetTransaction ¶
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.