Documentation ¶
Index ¶
- Variables
- type Item
- type Pool
- type PriorityQueue
- func (spq *PriorityQueue) Exists(extHash common.Hash) bool
- func (spq *PriorityQueue) Len() int
- func (spq *PriorityQueue) Peek() *ValidTransaction
- func (spq *PriorityQueue) Pending() []*ValidTransaction
- func (spq *PriorityQueue) Pop() *ValidTransaction
- func (spq *PriorityQueue) PopWithTimer(timerCh <-chan time.Time) (transaction *ValidTransaction)
- func (spq *PriorityQueue) Push(txn *ValidTransaction) (common.Hash, error)
- func (spq *PriorityQueue) RemoveExtrinsic(ext types.Extrinsic)
- type Status
- type ValidTransaction
- type Validity
Constants ¶
This section is empty.
Variables ¶
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 (*Pool) Get ¶ added in v0.7.0
func (p *Pool) Get(extHash common.Hash) *ValidTransaction
Get returns a pointer to ValidTransaction or nil given an extinsic hash
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) Transactions ¶ added in v0.2.0
func (p *Pool) Transactions() []*ValidTransaction
Transactions returns all the transactions in the pool
type PriorityQueue ¶
PriorityQueue is a thread safe wrapper over `priorityQueue`
func NewPriorityQueue ¶
func NewPriorityQueue() *PriorityQueue
NewPriorityQueue creates new instance of PriorityQueue
func (*PriorityQueue) Exists ¶ added in v0.7.0
func (spq *PriorityQueue) Exists(extHash common.Hash) bool
Exists returns true if a hash is in the txs map, false otherwise
func (*PriorityQueue) Len ¶ added in v0.7.0
func (spq *PriorityQueue) Len() int
Len return the current length of the queue
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) PopWithTimer ¶ added in v0.7.0
func (spq *PriorityQueue) PopWithTimer(timerCh <-chan time.Time) (transaction *ValidTransaction)
PopWithTimer returns the next valid transaction from the queue. When the timer expires, it returns `nil`.
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 Status ¶ added in v0.7.0
type Status int64
Status represents possible transaction statuses.
The status events can be grouped based on their kinds as: 1. Entering/Moving within the pool:
- `Future`
- `Ready`
2. Inside `Ready` queue:
- `Broadcast`
3. Leaving the pool:
- `InBlock`
- `Invalid`
- `Usurped`
- `Dropped` 4. Re-entering the pool:
- `Retracted` 5. Block finalized:
- `Finalized`
- `FinalityTimeout`
const ( // Future status occurs when transaction is part of the future queue. Future Status = iota // Ready status occurs when transaction is part of the ready queue. Ready // Broadcast status occurs when transaction has been broadcast to the given peers. Broadcast // InBlock status occurs when transaction has been included in block with given // hash. InBlock // Retracted status occurs when the block this transaction was included in has // been retracted. Retracted // FinalityTimeout status occurs when the maximum number of finality watchers // has been reached, // old watchers are being removed. FinalityTimeout // Finalized status occurs when transaction has been finalized by a finality-gadget, // e.g GRANDPA Finalized // Usurped status occurs when transaction has been replaced in the pool, by another // transaction that provides the same tags. (e.g. same (sender, nonce)). Usurped // Dropped status occurs when transaction has been dropped from the pool because // of the limit. Dropped // Invalid status occurs when transaction is no longer valid in the current state. Invalid )
type ValidTransaction ¶
ValidTransaction struct
func NewValidTransaction ¶
func NewValidTransaction(extrinsic types.Extrinsic, validity *Validity) *ValidTransaction
NewValidTransaction returns ValidTransaction