|
rippled
|
Transaction Queue. More...
#include <TxQ.h>

Classes | |
| struct | FeeAndSeq |
| class | FeeMetrics |
| Track and use the fee escalation metrics of the current open ledger. More... | |
| class | MaybeTx |
| Represents a transaction in the queue which may be applied later to the open ledger. More... | |
| struct | Metrics |
| Structure returned by TxQ::getMetrics, expressed in reference fee level units. More... | |
| class | OrderCandidates |
| Used for sorting MaybeTx. More... | |
| struct | Setup |
| Structure used to customize TxQ behavior. More... | |
| struct | TxDetails |
| Structure that describes a transaction in the queue waiting to be applied to the current open ledger. More... | |
| class | TxQAccount |
| Used to represent an account to the queue, and stores the transactions queued for that account by SeqProxy. More... | |
Public Member Functions | |
| TxQ (Setup const &setup, beast::Journal j) | |
| Constructor. | |
| virtual | ~TxQ () |
| Destructor. | |
| ApplyResult | apply (Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, ApplyFlags flags, beast::Journal j) |
| Add a new transaction to the open ledger, hold it in the queue, or reject it. | |
| bool | accept (Application &app, OpenView &view) |
| Fill the new open ledger with transactions from the queue. | |
| void | processClosedLedger (Application &app, ReadView const &view, bool timeLeap) |
| Update fee metrics and clean up the queue in preparation for the next ledger. | |
| SeqProxy | nextQueuableSeq (std::shared_ptr< SLE const > const &sleAccount) const |
| Return the next sequence that would go in the TxQ for an account. | |
| Metrics | getMetrics (OpenView const &view) const |
| Returns fee metrics in reference fee level units. | |
| FeeAndSeq | getTxRequiredFeeAndSeq (OpenView const &view, std::shared_ptr< STTx const > const &tx) const |
| Returns minimum required fee for tx and two sequences: first valid sequence for this account in current ledger and first available sequence for transaction. | |
| std::vector< TxDetails > | getAccountTxs (AccountID const &account) const |
| Returns information about the transactions currently in the queue for the account. | |
| std::vector< TxDetails > | getTxs () const |
| Returns information about all transactions currently in the queue. | |
| Json::Value | doRPC (Application &app) const |
Summarize current fee metrics for the fee RPC command. | |
Static Public Attributes | |
| static constexpr FeeLevel64 | baseLevel {256} |
| Fee level for single-signed reference transaction. | |
Private Types | |
| using | FeeHook = boost::intrusive::member_hook< MaybeTx, boost::intrusive::set_member_hook<>, &MaybeTx::byFeeListHook > |
| using | FeeMultiSet = boost::intrusive::multiset< MaybeTx, FeeHook, boost::intrusive::compare< OrderCandidates > > |
| using | AccountMap = std::map< AccountID, TxQAccount > |
Private Member Functions | |
| SeqProxy | nextQueuableSeqImpl (std::shared_ptr< SLE const > const &sleAccount, std::lock_guard< std::mutex > const &) const |
| std::optional< ApplyResult > | tryDirectApply (Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, ApplyFlags flags, beast::Journal j) |
| std::optional< TxQAccount::TxMap::iterator > | removeFromByFee (std::optional< TxQAccount::TxMap::iterator > const &replacedTxIter, std::shared_ptr< STTx const > const &tx) |
| template<size_t fillPercentage = 100> | |
| bool | isFull () const |
Is the queue at least fillPercentage full? | |
| TER | canBeHeld (STTx const &, ApplyFlags const, OpenView const &, std::shared_ptr< SLE const > const &sleAccount, AccountMap::iterator const &, std::optional< TxQAccount::TxMap::iterator > const &, std::lock_guard< std::mutex > const &lock) |
| Checks if the indicated transaction fits the conditions for being stored in the queue. | |
| FeeMultiSet::iterator_type | erase (FeeMultiSet::const_iterator_type) |
| Erase and return the next entry in byFee_ (lower fee level) | |
| FeeMultiSet::iterator_type | eraseAndAdvance (FeeMultiSet::const_iterator_type) |
| Erase and return the next entry for the account (if fee level is higher), or next entry in byFee_ (lower fee level). | |
| TxQAccount::TxMap::iterator | erase (TxQAccount &txQAccount, TxQAccount::TxMap::const_iterator begin, TxQAccount::TxMap::const_iterator end) |
| Erase a range of items, based on TxQAccount::TxMap iterators. | |
| ApplyResult | tryClearAccountQueueUpThruTx (Application &app, OpenView &view, STTx const &tx, AccountMap::iterator const &accountIter, TxQAccount::TxMap::iterator, FeeLevel64 feeLevelPaid, PreflightResult const &pfResult, std::size_t const txExtraCount, ApplyFlags flags, FeeMetrics::Snapshot const &metricsSnapshot, beast::Journal j) |
All-or-nothing attempt to try to apply the queued txs for accountIter up to and including tx. | |
Static Private Member Functions | |
| static FeeLevel64 | getRequiredFeeLevel (OpenView &view, ApplyFlags flags, FeeMetrics::Snapshot const &metricsSnapshot, std::lock_guard< std::mutex > const &lock) |
Private Attributes | |
| Setup const | setup_ |
| Setup parameters used to control the behavior of the queue. | |
| beast::Journal const | j_ |
| Journal. | |
| FeeMetrics | feeMetrics_ |
| Tracks the current state of the queue. | |
| FeeMultiSet | byFee_ |
| The queue itself: the collection of transactions ordered by fee level. | |
| AccountMap | byAccount_ |
| All of the accounts which currently have any transactions in the queue. | |
| std::optional< size_t > | maxSize_ |
| Maximum number of transactions allowed in the queue based on the current metrics. | |
| LedgerHash | parentHash_ {beast::zero} |
| parentHash_ used for logging only | |
| std::mutex | mutex_ |
| Most queue operations are done under the master lock, but use this mutex for the RPC "fee" command, which isn't. | |
Transaction Queue.
Used to manage transactions in conjunction with fee escalation.
Once enough transactions are added to the open ledger, the required fee will jump dramatically. If additional transactions are added, the fee will grow exponentially from there.
Transactions that don't have a high enough fee to be applied to the ledger are added to the queue in order from highest fee level to lowest. Whenever a new ledger is accepted as validated, transactions are first applied from the queue to the open ledger in fee level order until either all transactions are applied or the fee again jumps too high for the remaining transactions.
For further information and a high-level overview of how transactions are processed with the TxQ, see FeeEscalation.md
|
private |
|
private |
|
private |
| xrpl::TxQ::TxQ | ( | Setup const & | setup, |
| beast::Journal | j | ||
| ) |
| ApplyResult xrpl::TxQ::apply | ( | Application & | app, |
| OpenView & | view, | ||
| std::shared_ptr< STTx const > const & | tx, | ||
| ApplyFlags | flags, | ||
| beast::Journal | j | ||
| ) |
| bool xrpl::TxQ::accept | ( | Application & | app, |
| OpenView & | view | ||
| ) |
Fill the new open ledger with transactions from the queue.
view. | void xrpl::TxQ::processClosedLedger | ( | Application & | app, |
| ReadView const & | view, | ||
| bool | timeLeap | ||
| ) |
Update fee metrics and clean up the queue in preparation for the next ledger.
ledgersInQueue ledgers or queueSizeMin transactions. Any transactions for which the LastLedgerSequence has passed are removed from the queue, and any account objects that have no candidates under them are removed. | SeqProxy xrpl::TxQ::nextQueuableSeq | ( | std::shared_ptr< SLE const > const & | sleAccount | ) | const |
| TxQ::Metrics xrpl::TxQ::getMetrics | ( | OpenView const & | view | ) | const |
| TxQ::FeeAndSeq xrpl::TxQ::getTxRequiredFeeAndSeq | ( | OpenView const & | view, |
| std::shared_ptr< STTx const > const & | tx | ||
| ) | const |
Returns minimum required fee for tx and two sequences: first valid sequence for this account in current ledger and first available sequence for transaction.
| view | current open ledger |
| tx | the transaction |
| std::vector< TxQ::TxDetails > xrpl::TxQ::getAccountTxs | ( | AccountID const & | account | ) | const |
| std::vector< TxQ::TxDetails > xrpl::TxQ::getTxs | ( | ) | const |
| Json::Value xrpl::TxQ::doRPC | ( | Application & | app | ) | const |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
Erase and return the next entry in byFee_ (lower fee level)
|
private |
|
private |
Erase a range of items, based on TxQAccount::TxMap iterators.
|
private |
|
staticconstexpr |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |