transaction

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTransactionExists = errors.New("transaction is already in queue")

ErrTransactionExists is returned when trying to add a transaction to the queue that already exists

Functions

This section is empty.

Types

type Item added in v0.2.0

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

An Item is something we manage in a priority queue.

type Pool

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

Pool represents the transaction pool

func NewPool added in v0.2.0

func NewPool() *Pool

NewPool returns a new empty Pool

func (*Pool) Insert added in v0.2.0

func (p *Pool) Insert(tx *ValidTransaction) common.Hash

Insert inserts a transaction into the pool

func (*Pool) Remove added in v0.2.0

func (p *Pool) Remove(hash common.Hash)

Remove removes a transaction from the pool

func (*Pool) Transactions added in v0.2.0

func (p *Pool) Transactions() []*ValidTransaction

Transactions returns all the transactions in the pool

type PriorityQueue

type PriorityQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PriorityQueue is a thread safe wrapper over `priorityQueue`

func NewPriorityQueue

func NewPriorityQueue() *PriorityQueue

NewPriorityQueue creates new instance of PriorityQueue

func (*PriorityQueue) Peek

func (spq *PriorityQueue) Peek() *ValidTransaction

Peek returns the next item without removing it from the queue

func (*PriorityQueue) Pending

func (spq *PriorityQueue) Pending() []*ValidTransaction

Pending returns all the transactions currently in the queue

func (*PriorityQueue) Pop

func (spq *PriorityQueue) Pop() *ValidTransaction

Pop removes the transaction with has the highest priority value from the queue and returns it. If there are multiple transaction with same priority value then it return them in FIFO order.

func (*PriorityQueue) Push

func (spq *PriorityQueue) Push(txn *ValidTransaction) (common.Hash, error)

Push inserts a valid transaction with priority p into the queue

func (*PriorityQueue) RemoveExtrinsic

func (spq *PriorityQueue) RemoveExtrinsic(ext types.Extrinsic)

RemoveExtrinsic removes an extrinsic from the queue

type ValidTransaction

type ValidTransaction struct {
	Extrinsic types.Extrinsic
	Validity  *Validity
}

ValidTransaction struct

func NewValidTransaction

func NewValidTransaction(extrinsic types.Extrinsic, validity *Validity) *ValidTransaction

NewValidTransaction returns ValidTransaction

func (*ValidTransaction) Encode

func (vt *ValidTransaction) Encode() ([]byte, error)

Encode SCALE encodes the transaction

type Validity

type Validity struct {
	Priority  uint64
	Requires  [][]byte
	Provides  [][]byte
	Longevity uint64
	Propagate bool
}

Validity struct see: https://github.com/paritytech/substrate/blob/5420de3face1349a97eb954ae71c5b0b940c31de/core/sr-primitives/src/transaction_validity.rs#L178

func NewValidity

func NewValidity(priority uint64, requires, provides [][]byte, longevity uint64, propagate bool) *Validity

NewValidity returns Validity

Jump to

Keyboard shortcuts

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