Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::eth::TransactionQueue Class Reference

A queue of Transactions, each stored as RLP. Maintains a transaction queue sorted by nonce diff and gas price. @threadsafe. More...

#include <TransactionQueue.h>

Classes

struct  Limits
 
struct  Status
 

Public Member Functions

 TransactionQueue (unsigned _limit=1024, unsigned _futureLimit=1024)
 TransactionQueue. More...
 
 TransactionQueue (Limits const &_l)
 
 ~TransactionQueue ()
 
void enqueue (RLP const &_data, h512 const &_nodeId)
 
ImportResult import (bytes const &_tx, IfDropped _ik=IfDropped::Ignore)
 
ImportResult import (Transaction const &_tx, IfDropped _ik=IfDropped::Ignore)
 
void drop (h256 const &_txHash)
 
unsigned waiting (Address const &_a) const
 
Transactions topTransactions (unsigned _limit, h256Hash const &_avoid=h256Hash()) const
 
h256Hash knownTransactions () const
 
u256 maxNonce (Address const &_a) const
 
void setFuture (h256 const &_t)
 
void dropGood (Transaction const &_t)
 
Status status () const
 
Limits limits () const
 
void clear ()
 Clear the queue. More...
 
template<class T >
Handler onReady (T const &_t)
 Register a handler that will be called once there is a new transaction imported. More...
 
template<class T >
Handler< ImportResult, h256 const &, h512 const & > onImport (T const &_t)
 Register a handler that will be called once asynchronous verification is comeplte an transaction has been imported. More...
 
template<class T >
Handler< h256 const & > onReplaced (T const &_t)
 Register a handler that will be called once asynchronous verification is comeplte an transaction has been imported. More...
 

Detailed Description

A queue of Transactions, each stored as RLP. Maintains a transaction queue sorted by nonce diff and gas price. @threadsafe.

Definition at line 44 of file TransactionQueue.h.

Constructor & Destructor Documentation

◆ TransactionQueue() [1/2]

TransactionQueue::TransactionQueue ( unsigned  _limit = 1024,
unsigned  _futureLimit = 1024 
)

TransactionQueue.

Parameters
_limitMaximum number of pending transactions in the queue.
_futureLimitMaximum number of future nonce transactions.

Definition at line 33 of file TransactionQueue.cpp.

◆ TransactionQueue() [2/2]

dev::eth::TransactionQueue::TransactionQueue ( Limits const &  _l)
inline

Definition at line 53 of file TransactionQueue.h.

◆ ~TransactionQueue()

TransactionQueue::~TransactionQueue ( )

Definition at line 46 of file TransactionQueue.cpp.

Member Function Documentation

◆ clear()

void TransactionQueue::clear ( )

Clear the queue.

Definition at line 344 of file TransactionQueue.cpp.

◆ drop()

void TransactionQueue::drop ( h256 const &  _txHash)

Remove transaction from the queue

Parameters
_txHashTrasnaction hash

Definition at line 323 of file TransactionQueue.cpp.

◆ dropGood()

void TransactionQueue::dropGood ( Transaction const &  _t)

Drop a trasnaction from the list if exists and move following future trasnactions to current (if any)

Parameters
_tTransaction hash

Definition at line 335 of file TransactionQueue.cpp.

◆ enqueue()

void TransactionQueue::enqueue ( RLP const &  _data,
h512 const &  _nodeId 
)

Add transaction to the queue to be verified and imported.

Parameters
_dataRLP encoded transaction data.
_nodeIdOptional network identified of a node transaction comes from.

Definition at line 356 of file TransactionQueue.cpp.

◆ import() [1/2]

ImportResult dev::eth::TransactionQueue::import ( bytes const &  _tx,
IfDropped  _ik = IfDropped::Ignore 
)
inline

Verify and add transaction to the queue synchronously.

Parameters
_txRLP encoded transaction data.
_ikSet to Retry to force re-addinga transaction that was previously dropped.
Returns
Import result code.

Definition at line 64 of file TransactionQueue.h.

◆ import() [2/2]

ImportResult TransactionQueue::import ( Transaction const &  _tx,
IfDropped  _ik = IfDropped::Ignore 
)

Verify and add transaction to the queue synchronously.

Parameters
_txTrasnaction data.
_ikSet to Retry to force re-addinga transaction that was previously dropped.
Returns
Import result code.

Definition at line 79 of file TransactionQueue.cpp.

◆ knownTransactions()

h256Hash TransactionQueue::knownTransactions ( ) const

Get a hash set of transactions in the queue

Returns
A hash set of all transactions in the queue

Definition at line 112 of file TransactionQueue.cpp.

◆ limits()

Limits dev::eth::TransactionQueue::limits ( ) const
inline
Returns
the transacrtion limits on current/future.

Definition at line 113 of file TransactionQueue.h.

◆ maxNonce()

u256 TransactionQueue::maxNonce ( Address const &  _a) const

Get max nonce for an account

Returns
Max transaction nonce for account in the queue

Definition at line 184 of file TransactionQueue.cpp.

◆ onImport()

template<class T >
Handler<ImportResult, h256 const&, h512 const&> dev::eth::TransactionQueue::onImport ( T const &  _t)
inline

Register a handler that will be called once asynchronous verification is comeplte an transaction has been imported.

Definition at line 122 of file TransactionQueue.h.

◆ onReady()

template<class T >
Handler dev::eth::TransactionQueue::onReady ( T const &  _t)
inline

Register a handler that will be called once there is a new transaction imported.

Definition at line 119 of file TransactionQueue.h.

◆ onReplaced()

template<class T >
Handler<h256 const&> dev::eth::TransactionQueue::onReplaced ( T const &  _t)
inline

Register a handler that will be called once asynchronous verification is comeplte an transaction has been imported.

Definition at line 125 of file TransactionQueue.h.

◆ setFuture()

void TransactionQueue::setFuture ( h256 const &  _t)

Mark transaction as future. It wont be retured in topTransactions list until a transaction with a preceeding nonce is imported or marked with dropGood

Parameters
_tTransaction hash

Definition at line 253 of file TransactionQueue.cpp.

◆ status()

Status dev::eth::TransactionQueue::status ( ) const
inline
Returns
the status of the transaction queue.

Definition at line 110 of file TransactionQueue.h.

◆ topTransactions()

Transactions TransactionQueue::topTransactions ( unsigned  _limit,
h256Hash const &  _avoid = h256Hash() 
) const

Get top transactions from the queue. Returned transactions are not removed from the queue automatically.

Parameters
_limitMax number of transactions to return.
_avoidTransactions to avoid returning.
Returns
up to _limit transactions ordered by nonce and gas price.

Definition at line 102 of file TransactionQueue.cpp.

◆ waiting()

unsigned TransactionQueue::waiting ( Address const &  _a) const

Get number of pending transactions for account.

Returns
Pending transaction count.

Definition at line 240 of file TransactionQueue.cpp.


The documentation for this class was generated from the following files: