rippled
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ripple::TxQ::FeeMetrics Class Reference

Track and use the fee escalation metrics of the current open ledger. More...

Collaboration diagram for ripple::TxQ::FeeMetrics:
Collaboration graph
[legend]

Classes

struct  Snapshot
 Snapshot of the externally relevant FeeMetrics fields at any given time. More...
 

Public Member Functions

 FeeMetrics (Setup const &setup, beast::Journal j)
 Constructor.
 
std::size_t update (Application &app, ReadView const &view, bool timeLeap, TxQ::Setup const &setup)
 Updates fee metrics based on the transactions in the ReadView for use in fee escalation calculations.
 
Snapshot getSnapshot () const
 Get the current Snapshot.
 

Static Public Member Functions

static FeeLevel64 scaleFeeLevel (Snapshot const &snapshot, OpenView const &view)
 Use the number of transactions in the current open ledger to compute the fee level a transaction must pay to bypass the queue.
 
static std::pair< bool, FeeLevel64escalatedSeriesFeeLevel (Snapshot const &snapshot, OpenView const &view, std::size_t extraCount, std::size_t seriesSize)
 Computes the total fee level for all transactions in a series.
 

Private Attributes

std::size_t const minimumTxnCount_
 Minimum value of txnsExpected.
 
std::size_t const targetTxnCount_
 Number of transactions per ledger that fee escalation "works towards".
 
std::optional< std::size_t > const maximumTxnCount_
 Maximum value of txnsExpected.
 
std::size_t txnsExpected_
 Number of transactions expected per ledger.
 
boost::circular_buffer< std::size_trecentTxnCounts_
 Recent history of transaction counts that exceed the targetTxnCount_.
 
FeeLevel64 escalationMultiplier_
 Based on the median fee of the LCL.
 
beast::Journal const j_
 Journal.
 

Detailed Description

Track and use the fee escalation metrics of the current open ledger.

Does the work of scaling fees as the open ledger grows.

Definition at line 358 of file TxQ.h.

Constructor & Destructor Documentation

◆ FeeMetrics()

ripple::TxQ::FeeMetrics::FeeMetrics ( Setup const &  setup,
beast::Journal  j 
)

Constructor.

Definition at line 383 of file TxQ.h.

Member Function Documentation

◆ update()

std::size_t ripple::TxQ::FeeMetrics::update ( Application app,
ReadView const &  view,
bool  timeLeap,
TxQ::Setup const &  setup 
)

Updates fee metrics based on the transactions in the ReadView for use in fee escalation calculations.

Parameters
appRippled Application object.
viewView of the LCL that was just closed or received.
timeLeapIndicates that rippled is under load so fees should grow faster.
setupCustomization params.

Definition at line 65 of file TxQ.cpp.

◆ getSnapshot()

Snapshot ripple::TxQ::FeeMetrics::getSnapshot ( ) const

Get the current Snapshot.

Definition at line 436 of file TxQ.h.

◆ scaleFeeLevel()

FeeLevel64 ripple::TxQ::FeeMetrics::scaleFeeLevel ( Snapshot const &  snapshot,
OpenView const &  view 
)
static

Use the number of transactions in the current open ledger to compute the fee level a transaction must pay to bypass the queue.

Parameters
viewCurrent open ledger.
Returns
A fee level value.

Definition at line 154 of file TxQ.cpp.

◆ escalatedSeriesFeeLevel()

std::pair< bool, FeeLevel64 > ripple::TxQ::FeeMetrics::escalatedSeriesFeeLevel ( Snapshot const &  snapshot,
OpenView const &  view,
std::size_t  extraCount,
std::size_t  seriesSize 
)
static

Computes the total fee level for all transactions in a series.

Assumes that there are already more than txnsExpected_ txns between the view and extraCount. If there aren't, the result will be sensible (e.g. there won't be any underflows or overflows), but the level will be higher than actually required.

Note
A "series" is a set of transactions for the same account. In the context of this function, the series is already in the queue, and the series starts with the account's current sequence number. This function is called by tryClearAccountQueueUpThruTx to figure out if a newly submitted transaction is paying enough to get all of the queued transactions plus itself out of the queue and into the open ledger while accounting for the escalating fee as each one is processed. The idea is that if a series of transactions are taking too long to get out of the queue, a user can "rescue" them without having to resubmit each one with an individually higher fee.
Parameters
viewCurrent open / working ledger. (May be a sandbox.)
extraCountNumber of additional transactions to count as in the ledger. (If view is a sandbox, should be the number of transactions in the parent ledger.)
seriesSizeTotal number of transactions in the series to be processed.
Returns
A std::pair indicating whether the calculation result overflows.

Definition at line 215 of file TxQ.cpp.

Member Data Documentation

◆ minimumTxnCount_

std::size_t const ripple::TxQ::FeeMetrics::minimumTxnCount_
private

Minimum value of txnsExpected.

Definition at line 362 of file TxQ.h.

◆ targetTxnCount_

std::size_t const ripple::TxQ::FeeMetrics::targetTxnCount_
private

Number of transactions per ledger that fee escalation "works towards".

Definition at line 365 of file TxQ.h.

◆ maximumTxnCount_

std::optional<std::size_t> const ripple::TxQ::FeeMetrics::maximumTxnCount_
private

Maximum value of txnsExpected.

Definition at line 367 of file TxQ.h.

◆ txnsExpected_

std::size_t ripple::TxQ::FeeMetrics::txnsExpected_
private

Number of transactions expected per ledger.

One more than this value will be accepted before escalation kicks in.

Definition at line 371 of file TxQ.h.

◆ recentTxnCounts_

boost::circular_buffer<std::size_t> ripple::TxQ::FeeMetrics::recentTxnCounts_
private

Recent history of transaction counts that exceed the targetTxnCount_.

Definition at line 374 of file TxQ.h.

◆ escalationMultiplier_

FeeLevel64 ripple::TxQ::FeeMetrics::escalationMultiplier_
private

Based on the median fee of the LCL.

Used when fee escalation kicks in.

Definition at line 377 of file TxQ.h.

◆ j_

beast::Journal const ripple::TxQ::FeeMetrics::j_
private

Journal.

Definition at line 379 of file TxQ.h.