sequence

package
v0.0.0-...-2e41b90 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sequence providers helpers to manage sequence numbers on behalf of horizon clients. See Manager for more details on the api.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMoreRoom  = errors.New("queue full")
	ErrBadSequence = errors.New("bad sequence")
)

Functions

This section is empty.

Types

type AccountTxSubmissionQueue

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

AccountTxSubmissionQueue manages the submission queue for a single source account. The transaction system uses Push to enqueue submissions for given sequence numbers.

AccountTxSubmissionQueue maintains a priority queue of pending submissions, and when updated (via the NotifyLastAccountSequence() method) with the current sequence number of the account being managed, queued submissions that can be acted upon will be unblocked.

func NewAccountTxSubmissionQueue

func NewAccountTxSubmissionQueue() *AccountTxSubmissionQueue

NewAccountTxSubmissionQueue creates a new *AccountTxSubmissionQueue

func (*AccountTxSubmissionQueue) NotifyLastAccountSequence

func (q *AccountTxSubmissionQueue) NotifyLastAccountSequence(sequence uint64)

NotifyLastAccountSequence notifies the queue that the provided sequence number is the latest seen value for the account that this queue manages submissions for.

This function is monotonic... calling it with a sequence number lower than the latest seen sequence number is a noop.

func (*AccountTxSubmissionQueue) Push

func (q *AccountTxSubmissionQueue) Push(sequence uint64, minSeqNum *uint64) <-chan error

Push enqueues the intent to submit a transaction at the provided sequence number and returns a channel that will emit when it is safe for the client to do so.

Push does not perform any triggering (which occurs in NotifyLastAccountSequence(), even if the current sequence number for this queue is the same as the provided sequence, to keep internal complexity much lower. Given that, the recommended usage pattern is:

  1. Push the submission onto the queue
  2. Load the current sequence number for the source account from the DB
  3. Call NotifyLastAccountSequence() with the result from step 2 to trigger the submission if possible

func (*AccountTxSubmissionQueue) Size

func (q *AccountTxSubmissionQueue) Size() int

Size returns the count of currently buffered submissions in the queue.

type Manager

type Manager struct {
	MaxSize int
	// contains filtered or unexported fields
}

Manager provides a system for tracking the transaction submission queue for a set of addresses. Requests to submit at a certain sequence number are registered using the Push() method, and as the system is updated with account sequence information (through the Update() method) requests are notified that they can safely submit to stellar-core.

func NewManager

func NewManager() *Manager

NewManager returns a new manager

func (*Manager) Addresses

func (m *Manager) Addresses() []string

func (*Manager) NotifyLastAccountSequences

func (m *Manager) NotifyLastAccountSequences(updates map[string]uint64)

NotifyLastAccountSequences notifies the manager of newly loaded account sequence information. The manager uses this information to notify requests to submit that they should proceed. See AccountTxSubmissionQueue#NotifyLastAccountSequence for the actual meat of the logic.

func (*Manager) Push

func (m *Manager) Push(address string, sequence uint64, minSeqNum *uint64) <-chan error

Push registers an intent to submit a transaction for the provided address at the provided sequence. A channel is returned that will be written to when the requester should attempt the submission.

func (*Manager) Size

func (m *Manager) Size() int

Size returns the count of submissions buffered within this manager.

func (*Manager) String

func (m *Manager) String() string

Jump to

Keyboard shortcuts

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