Documentation ¶
Overview ¶
Package txsub provides the machinery that aurora uses to submit transactions to the hcnet network and track their progress. It also helps to hide some of the complex asynchronous nature of transaction submission, waiting to respond to submitters when no definitive state is known.
Index ¶
- Variables
- type AuroraDB
- type FailedTransactionError
- func (err *FailedTransactionError) Error() string
- func (fte *FailedTransactionError) OperationResultCodes() (result []string, err error)
- func (fte *FailedTransactionError) Result() (result xdr.TransactionResult, err error)
- func (fte *FailedTransactionError) TransactionResultCodes(transactionHash string) (result ResultCodes, err error)
- type Listener
- type OpenSubmissionList
- type Result
- type ResultCodes
- type SubmissionResult
- type Submitter
- type System
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoResults = errors.New("No result found") ErrCanceled = errors.New("canceled") ErrTimeout = errors.New("timeout") // ErrBadSequence is a canned error response for transactions whose sequence // number is wrong. ErrBadSequence = &FailedTransactionError{"AAAAAAAAAAD////7AAAAAA==", ""} )
Functions ¶
This section is empty.
Types ¶
type AuroraDB ¶ added in v1.11.1
type AuroraDB interface { GetLatestHistoryLedger(ctx context.Context) (uint32, error) PreFilteredTransactionByHash(ctx context.Context, dest interface{}, hash string) error TransactionByHash(ctx context.Context, dest interface{}, hash string) error AllTransactionsByHashesSinceLedger(ctx context.Context, hashes []string, sinceLedgerSeq uint32) ([]history.Transaction, error) GetSequenceNumbers(ctx context.Context, addresses []string) (map[string]uint64, error) BeginTx(context.Context, *sql.TxOptions) error Rollback() error NoRows(error) bool }
type FailedTransactionError ¶
type FailedTransactionError struct { ResultXDR string // DiagnosticEventsXDR is a base64-encoded []xdr.DiagnosticEvent DiagnosticEventsXDR string }
FailedTransactionError represent an error that occurred because hcnet-core rejected the transaction. ResultXDR is a base64 encoded TransactionResult struct
func (*FailedTransactionError) Error ¶
func (err *FailedTransactionError) Error() string
func (*FailedTransactionError) OperationResultCodes ¶
func (fte *FailedTransactionError) OperationResultCodes() (result []string, err error)
func (*FailedTransactionError) Result ¶
func (fte *FailedTransactionError) Result() (result xdr.TransactionResult, err error)
func (*FailedTransactionError) TransactionResultCodes ¶ added in v1.11.1
func (fte *FailedTransactionError) TransactionResultCodes(transactionHash string) (result ResultCodes, err error)
type Listener ¶
type Listener chan<- Result
Listener represents some client who is interested in retrieving the result of a specific transaction.
type OpenSubmissionList ¶
type OpenSubmissionList interface { // Add registers the provided listener as interested in being notified when a // result is available for the provided transaction hash. Add(string, Listener) // Finish forwards the provided result on to any listeners and cleans up any // resources associated with the transaction that this result is for Finish(string, Result) // Clean removes any open submissions over the provided age. Clean(time.Duration) int // Pending return a list of transaction hashes that have at least one // listener registered to them in this list. Pending() []string }
OpenSubmissionList represents the structure that tracks pending transactions and forwards Result structs on to listeners as they become available.
NOTE: An implementation of this interface will be called from multiple go-routines concurrently.
NOTE: A Listener must be a buffered channel. A panic will trigger if you provide an unbuffered channel
func NewDefaultSubmissionList ¶
func NewDefaultSubmissionList() OpenSubmissionList
NewDefaultSubmissionList returns a list that manages open submissions purely in memory.
type Result ¶
type Result struct { // Any error that occurred during the retrieval of this result Err error // The full details of the transaction which was submitted // to Hcnet Core Transaction history.Transaction }
Result represents the response from a ResultProvider. Given no Err is set, the rest of the struct should be populated appropriately.
type ResultCodes ¶ added in v1.11.1
ResultCodes represents the result codes from a request attempting to submit a fee bump transaction.
type SubmissionResult ¶
type SubmissionResult struct { // Any error that occurred during the attempted submission. A nil value // indicates that the submission will or already is being considered for // inclusion in the ledger (i.e. A successful submission). Err error // Duration records the time it took to submit a transaction // to hcnet-core Duration time.Duration }
SubmissionResult gets returned in response to a call to Submitter.Submit. It represents a single discrete submission of a transaction envelope to the hcnet network.
func (SubmissionResult) IsBadSeq ¶
func (s SubmissionResult) IsBadSeq() (bool, error)
type Submitter ¶
type Submitter interface { // Submit sends the provided transaction envelope to hcnet-core Submit(context.Context, string) SubmissionResult }
Submitter represents the low-level "submit a transaction to hcnet-core" provider.
func NewDefaultSubmitter ¶
NewDefaultSubmitter returns a new, simple Submitter implementation that submits directly to the hcnet-core at `url` using the http client `h`.
type System ¶
type System struct { DB func(context.Context) AuroraDB Pending OpenSubmissionList Submitter Submitter SubmissionTimeout time.Duration Log *log.Entry LedgerState ledger.StateInterface Metrics struct { // OpenSubmissionsGauge tracks the count of "open" submissions (i.e. // submissions whose transactions haven't been confirmed successful or failed OpenSubmissionsGauge prometheus.Gauge // FailedSubmissionsCounter tracks the rate of failed transactions that have // been submitted to this process FailedSubmissionsCounter prometheus.Counter // SuccessfulSubmissionsCounter tracks the rate of successful transactions that // have been submitted to this process SuccessfulSubmissionsCounter prometheus.Counter } // contains filtered or unexported fields }
System represents a completely configured transaction submission system. Its methods tie together the various pieces used to reliably submit transactions to a hcnet-core instance.
func (*System) RegisterMetrics ¶ added in v1.11.1
func (sys *System) RegisterMetrics(registry *prometheus.Registry)
RegisterMetrics registers the prometheus metrics