rippled
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. More...
 
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. More...
 
Snapshot getSnapshot () const
 Get the current Snapshot. More...
 

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. More...
 
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. More...
 

Private Attributes

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

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 374 of file TxQ.h.

Constructor & Destructor Documentation

◆ FeeMetrics()

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

Constructor.

Definition at line 399 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 86 of file TxQ.cpp.

◆ getSnapshot()

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

Get the current Snapshot.

Definition at line 452 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 170 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 as returned from mulDiv indicating whether the calculation result overflows.

Definition at line 230 of file TxQ.cpp.

Member Data Documentation

◆ minimumTxnCount_

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

Minimum value of txnsExpected.

Definition at line 378 of file TxQ.h.

◆ targetTxnCount_

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

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

Definition at line 381 of file TxQ.h.

◆ maximumTxnCount_

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

Maximum value of txnsExpected.

Definition at line 383 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 387 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 390 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 393 of file TxQ.h.

◆ j_

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

Journal.

Definition at line 395 of file TxQ.h.