Documentation ¶
Overview ¶
Package transaction implements the runtime transaction semantics.
Index ¶
- Constants
- Variables
- func ValidateIOWriteLog(writeLog writelog.WriteLog, maxBatchSize, maxBatchSizeBytes uint64) error
- type CheckedTransaction
- func (t *CheckedTransaction) Hash() hash.Hash
- func (t *CheckedTransaction) Priority() uint64
- func (t *CheckedTransaction) Raw() []byte
- func (t *CheckedTransaction) Size() uint64
- func (t *CheckedTransaction) String() string
- func (t *CheckedTransaction) Weight(w Weight) uint64
- func (t *CheckedTransaction) Weights() map[Weight]uint64
- 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)
- type TxnCall
- type TxnCheckResult
- type TxnOutput
- type Weight
Constants ¶
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 ¶
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 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 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 the tree in a stable order (transactions are ordered by their hash).
type TxnCall ¶
type TxnCall struct { // Method is the called method name. Method string `json:"method"` // Args are the method arguments. Args interface{} `json:"args"` }
TxnCall is a transaction call.
type TxnCheckResult ¶
type TxnCheckResult struct { // PredictedReadWriteSet is the predicted read/write set. PredictedReadWriteSet ReadWriteSet `json:"predicted_rw_set"` }
TxnCheckResult is the result of a successful CheckTx call.
type TxnOutput ¶
type TxnOutput struct { // Success can be of any type. Success cbor.RawMessage // Error is a string describing the error message. Error *string }
TxnOutput is a transaction call output.