transaction

package
Version: v0.2103.7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: Apache-2.0 Imports: 14 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// MethodPriorityNormal is the normal method priority.
	MethodPriorityNormal = 0
	// MethodPriorityCritical is the priority for methods critical to the protocol operation.
	MethodPriorityCritical = 255
)
View Source
const MethodSeparator = "."

MethodSeparator is the separator used to separate backend name from method name.

Variables

View Source
var (
	// ErrInsufficientFeeBalance is the error returned when there is insufficient
	// balance to pay consensus fees.
	ErrInsufficientFeeBalance = errors.New(moduleName, 2, "transaction: insufficient balance to pay fees")

	// ErrGasPriceTooLow is the error returned when the gas price is too low.
	ErrGasPriceTooLow = errors.New(moduleName, 3, "transaction: gas price too low")
)
View Source
var (
	// ErrInvalidNonce is the error returned when a nonce is invalid.
	ErrInvalidNonce = errors.New(moduleName, 1, "transaction: invalid nonce")

	// ErrUpgradePending is the error returned when an upgrade is pending and the transaction thus
	// cannot be processed right now. The submitter should retry the transaction in this case.
	ErrUpgradePending = errors.New(moduleName, 4, "transaction: upgrade pending")

	// SignatureContext is the context used for signing transactions.
	SignatureContext = signature.NewContext("oasis-core/consensus: tx", signature.WithChainSeparation())
)

Functions

This section is empty.

Types

type Costs

type Costs map[Op]Gas

Costs defines gas costs for different operations.

type Fee

type Fee struct {
	// Amount is the fee amount to be paid.
	Amount quantity.Quantity `json:"amount"`
	// Gas is the maximum gas that a transaction can use.
	Gas Gas `json:"gas"`
}

Fee is the consensus transaction fee the sender wishes to pay for operations which require a fee to be paid to validators.

func (Fee) GasPrice

func (f Fee) GasPrice() *quantity.Quantity

GasPrice returns the gas price implied by the amount and gas.

func (Fee) PrettyPrint added in v0.2010.0

func (f Fee) PrettyPrint(ctx context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of the fee to the given writer.

func (Fee) PrettyType added in v0.2010.0

func (f Fee) PrettyType() (interface{}, error)

PrettyType returns a representation of Fee that can be used for pretty printing.

type Gas

type Gas uint64

Gas is the consensus gas representation.

type MethodMetadata added in v0.2100.0

type MethodMetadata struct {
	Priority MethodPriority
}

MethodMetadata is the method metadata.

type MethodMetadataProvider added in v0.2100.0

type MethodMetadataProvider interface {
	// MethodMetadata returns the method metadata.
	MethodMetadata() MethodMetadata
}

MethodMetadataProvider is the method metadata provider interface that can be implemented by method body types to provide additional method metadata.

type MethodName

type MethodName string

MethodName is a method name.

func NewMethodName

func NewMethodName(module, method string, bodyType interface{}) MethodName

NewMethodName creates a new method name.

Module and method pair must be unique. If they are not, this method will panic.

func (MethodName) BodyType

func (m MethodName) BodyType() interface{}

BodyType returns the registered body type associated with this method.

func (MethodName) IsCritical added in v0.2100.0

func (m MethodName) IsCritical() bool

IsCritical returns true if the method is critical for the operation of the protocol.

func (MethodName) Metadata added in v0.2100.0

func (m MethodName) Metadata() MethodMetadata

Metadata returns the method metadata.

func (MethodName) SanityCheck

func (m MethodName) SanityCheck() error

SanityCheck performs a basic sanity check on the method name.

type MethodPriority added in v0.2100.0

type MethodPriority uint8

MethodPriority is the method handling priority.

type Op

type Op string

Op identifies an operation that requires gas to run.

type PrettyTransaction

type PrettyTransaction struct {
	Nonce  uint64      `json:"nonce"`
	Fee    *Fee        `json:"fee,omitempty"`
	Method MethodName  `json:"method"`
	Body   interface{} `json:"body,omitempty"`
}

PrettyTransaction is used for pretty-printing transactions so that the actual content is displayed instead of the binary blob.

It should only be used for pretty printing.

type SignedTransaction

type SignedTransaction struct {
	signature.Signed
}

SignedTransaction is a signed transaction.

func Sign

func Sign(signer signature.Signer, tx *Transaction) (*SignedTransaction, error)

Sign signs a transaction.

func (*SignedTransaction) Hash

func (s *SignedTransaction) Hash() hash.Hash

Hash returns the cryptographic hash of the encoded transaction.

func (*SignedTransaction) Open

func (s *SignedTransaction) Open(tx *Transaction) error

Open first verifies the blob signature and then unmarshals the blob.

func (SignedTransaction) PrettyPrint

func (s SignedTransaction) PrettyPrint(ctx context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of the type to the given writer.

func (SignedTransaction) PrettyType

func (s SignedTransaction) PrettyType() (interface{}, error)

PrettyType returns a representation of the type that can be used for pretty printing.

type Transaction

type Transaction struct {
	// Nonce is a nonce to prevent replay.
	Nonce uint64 `json:"nonce"`
	// Fee is an optional fee that the sender commits to pay to execute this
	// transaction.
	Fee *Fee `json:"fee,omitempty"`

	// Method is the method that should be called.
	Method MethodName `json:"method"`
	// Body is the method call body.
	Body cbor.RawMessage `json:"body,omitempty"`
}

Transaction is an unsigned consensus transaction.

func NewTransaction

func NewTransaction(nonce uint64, fee *Fee, method MethodName, body interface{}) *Transaction

NewTransaction creates a new transaction.

func (Transaction) PrettyPrint

func (t Transaction) PrettyPrint(ctx context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of the transaction to the given writer.

func (Transaction) PrettyPrintBody

func (t Transaction) PrettyPrintBody(ctx context.Context, prefix string, w io.Writer)

PrettyPrintBody writes a pretty-printed representation of transaction's body to the given writer.

func (*Transaction) PrettyType

func (t *Transaction) PrettyType() (interface{}, error)

PrettyType returns a representation of the type that can be used for pretty printing.

func (*Transaction) SanityCheck

func (t *Transaction) SanityCheck() error

SanityCheck performs a basic sanity check on the transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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