rippled
TxQ.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012-19 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_TXQ_H_INCLUDED
21 #define RIPPLE_TXQ_H_INCLUDED
22 
23 #include <ripple/app/tx/applySteps.h>
24 #include <ripple/ledger/ApplyView.h>
25 #include <ripple/ledger/OpenView.h>
26 #include <ripple/protocol/STTx.h>
27 #include <ripple/protocol/SeqProxy.h>
28 #include <ripple/protocol/TER.h>
29 #include <boost/circular_buffer.hpp>
30 #include <boost/intrusive/set.hpp>
31 #include <optional>
32 
33 namespace ripple {
34 
35 class Application;
36 class Config;
37 
56 class TxQ
57 {
58 public:
60  static constexpr FeeLevel64 baseLevel{256};
61 
65  struct Setup
66  {
68  explicit Setup() = default;
69 
153  bool standAlone = false;
154  };
155 
160  struct Metrics
161  {
163  explicit Metrics() = default;
164 
183  };
184 
190  struct TxDetails
191  {
194  FeeLevel64 feeLevel_,
195  std::optional<LedgerIndex> const& lastValid_,
196  TxConsequences const& consequences_,
197  AccountID const& account_,
198  SeqProxy seqProxy_,
199  std::shared_ptr<STTx const> const& txn_,
200  int retriesRemaining_,
201  TER preflightResult_,
202  std::optional<TER> lastResult_)
203  : feeLevel(feeLevel_)
204  , lastValid(lastValid_)
205  , consequences(consequences_)
206  , account(account_)
207  , seqProxy(seqProxy_)
208  , txn(txn_)
209  , retriesRemaining(retriesRemaining_)
210  , preflightResult(preflightResult_)
211  , lastResult(lastResult_)
212  {
213  }
214 
252  };
253 
255  TxQ(Setup const& setup, beast::Journal j);
256 
258  virtual ~TxQ();
259 
270  apply(
271  Application& app,
272  OpenView& view,
273  std::shared_ptr<STTx const> const& tx,
274  ApplyFlags flags,
275  beast::Journal j);
276 
288  bool
289  accept(Application& app, OpenView& view);
290 
303  void
304  processClosedLedger(Application& app, ReadView const& view, bool timeLeap);
305 
307  SeqProxy
308  nextQueuableSeq(std::shared_ptr<SLE const> const& sleAccount) const;
309 
312  Metrics
313  getMetrics(OpenView const& view) const;
314 
315  struct FeeAndSeq
316  {
320  };
321 
331  FeeAndSeq
333  OpenView const& view,
334  std::shared_ptr<STTx const> const& tx) const;
335 
343  getAccountTxs(AccountID const& account, ReadView const& view) const;
344 
352  getTxs(ReadView const& view) const;
353 
359  doRPC(Application& app) const;
360 
361 private:
362  // Implementation for nextQueuableSeq(). The passed lock must be held.
363  SeqProxy
365  std::shared_ptr<SLE const> const& sleAccount,
366  std::lock_guard<std::mutex> const&) const;
367 
374  {
375  private:
389  boost::circular_buffer<std::size_t> recentTxnCounts_;
395 
396  public:
398  FeeMetrics(Setup const& setup, beast::Journal j)
400  setup.standAlone ? setup.minimumTxnInLedgerSA
401  : setup.minimumTxnInLedger)
402  , targetTxnCount_(
403  setup.targetTxnInLedger < minimumTxnCount_
405  : setup.targetTxnInLedger)
407  setup.maximumTxnInLedger
408  ? *setup.maximumTxnInLedger < targetTxnCount_
410  : *setup.maximumTxnInLedger
411  : std::optional<std::size_t>(std::nullopt))
413  , recentTxnCounts_(setup.ledgersInQueue)
414  , escalationMultiplier_(setup.minimumEscalationMultiplier)
415  , j_(j)
416  {
417  }
418 
430  update(
431  Application& app,
432  ReadView const& view,
433  bool timeLeap,
434  TxQ::Setup const& setup);
435 
438  struct Snapshot
439  {
440  // Number of transactions expected per ledger.
441  // One more than this value will be accepted
442  // before escalation kicks in.
444  // Based on the median fee of the LCL. Used
445  // when fee escalation kicks in.
447  };
448 
450  Snapshot
451  getSnapshot() const
452  {
454  }
455 
464  static FeeLevel64
465  scaleFeeLevel(Snapshot const& snapshot, OpenView const& view);
466 
499  Snapshot const& snapshot,
500  OpenView const& view,
501  std::size_t extraCount,
502  std::size_t seriesSize);
503  };
504 
509  class MaybeTx
510  {
511  public:
515  boost::intrusive::set_member_hook<> byFeeListHook;
516 
519 
523  TxID const txID;
561 
576  static constexpr int retriesAllowed = 10;
577 
578  public:
580  MaybeTx(
582  TxID const& txID,
584  ApplyFlags const flags,
585  PreflightResult const& pfresult);
586 
589  apply(Application& app, OpenView& view, beast::Journal j);
590 
593  TxConsequences const&
594  consequences() const
595  {
596  return pfresult->consequences;
597  }
598 
600  TxDetails
601  getTxDetails() const
602  {
603  return {
604  feeLevel,
605  lastValid,
606  consequences(),
607  account,
608  seqProxy,
609  txn,
611  pfresult->ter,
612  lastResult};
613  }
614  };
615 
618  {
619  public:
621  explicit GreaterFee() = default;
622 
624  bool
625  operator()(const MaybeTx& lhs, const MaybeTx& rhs) const
626  {
627  return lhs.feeLevel > rhs.feeLevel;
628  }
629  };
630 
635  {
636  public:
638 
643  /* If this account has had any transaction retry more than
644  `retriesAllowed` times so that it was dropped from the
645  queue, then all other transactions for this account will
646  be given at most 2 attempts before being removed. Helps
647  prevent wasting resources on retries that are more likely
648  to fail.
649  */
650  bool retryPenalty = false;
651  /* If this account has had any transaction fail or expire,
652  then when the queue is nearly full, transactions from
653  this account will be discarded. Helps prevent the queue
654  from getting filled and wedged.
655  */
656  bool dropPenalty = false;
657 
658  public:
660  explicit TxQAccount(std::shared_ptr<STTx const> const& txn);
662  explicit TxQAccount(const AccountID& account);
663 
666  getTxnCount() const
667  {
668  return transactions.size();
669  }
670 
672  bool
673  empty() const
674  {
675  return !getTxnCount();
676  }
677 
679  TxMap::const_iterator
680  getPrevTx(SeqProxy seqProx) const;
681 
683  MaybeTx&
684  add(MaybeTx&&);
685 
691  bool
692  remove(SeqProxy seqProx);
693  };
694 
695  // Helper function returns requiredFeeLevel.
696  FeeLevel64
698  OpenView& view,
699  ApplyFlags flags,
700  FeeMetrics::Snapshot const& metricsSnapshot,
701  std::lock_guard<std::mutex> const& lock) const;
702 
703  // Helper function for TxQ::apply. If a transaction's fee is high enough,
704  // attempt to directly apply that transaction to the ledger.
707  Application& app,
708  OpenView& view,
709  std::shared_ptr<STTx const> const& tx,
710  ApplyFlags flags,
711  beast::Journal j);
712 
713  // Helper function that removes a replaced entry in _byFee.
716  std::optional<TxQAccount::TxMap::iterator> const& replacedTxIter,
717  std::shared_ptr<STTx const> const& tx);
718 
719  using FeeHook = boost::intrusive::member_hook<
720  MaybeTx,
721  boost::intrusive::set_member_hook<>,
723 
724  using FeeMultiSet = boost::intrusive::
725  multiset<MaybeTx, FeeHook, boost::intrusive::compare<GreaterFee>>;
726 
728 
730  Setup const setup_;
733 
759 
764 
765 private:
767  template <size_t fillPercentage = 100>
768  bool
769  isFull() const;
770 
774  TER
775  canBeHeld(
776  STTx const&,
777  ApplyFlags const,
778  OpenView const&,
779  std::shared_ptr<SLE const> const& sleAccount,
780  AccountMap::iterator const&,
782  std::lock_guard<std::mutex> const& lock);
783 
785  FeeMultiSet::iterator_type erase(FeeMultiSet::const_iterator_type);
790  FeeMultiSet::iterator_type eraseAndAdvance(
791  FeeMultiSet::const_iterator_type);
793  TxQAccount::TxMap::iterator
794  erase(
795  TxQAccount& txQAccount,
796  TxQAccount::TxMap::const_iterator begin,
797  TxQAccount::TxMap::const_iterator end);
798 
806  Application& app,
807  OpenView& view,
808  STTx const& tx,
809  AccountMap::iterator const& accountIter,
810  TxQAccount::TxMap::iterator,
811  FeeLevel64 feeLevelPaid,
812  PreflightResult const& pfresult,
813  std::size_t const txExtraCount,
814  ApplyFlags flags,
815  FeeMetrics::Snapshot const& metricsSnapshot,
816  beast::Journal j);
817 };
818 
823 setup_TxQ(Config const&);
824 
825 template <class T>
826 XRPAmount
827 toDrops(FeeLevel<T> const& level, XRPAmount const& baseFee)
828 {
829  if (auto const drops = mulDiv(level, baseFee, TxQ::baseLevel); drops.first)
830  return drops.second;
831 
833 }
834 
835 inline FeeLevel64
836 toFeeLevel(XRPAmount const& drops, XRPAmount const& baseFee)
837 {
838  if (auto const feeLevel = mulDiv(drops, TxQ::baseLevel, baseFee);
839  feeLevel.first)
840  return feeLevel.second;
841 
843 }
844 
845 } // namespace ripple
846 
847 #endif
ripple::TxQ::setup_
const Setup setup_
Setup parameters used to control the behavior of the queue.
Definition: TxQ.h:730
ripple::setup_TxQ
TxQ::Setup setup_TxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
Definition: TxQ.cpp:1840
ripple::TxQ::Metrics::Metrics
Metrics()=default
Default constructor.
ripple::TxQ::tryClearAccountQueueUpThruTx
std::pair< TER, bool > 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.
Definition: TxQ.cpp:516
ripple::Application
Definition: Application.h:103
ripple::TxQ::TxDetails::lastValid
std::optional< LedgerIndex > lastValid
LastValidLedger field of the queued transaction, if any.
Definition: TxQ.h:218
ripple::TxQ::Metrics::minProcessingFeeLevel
FeeLevel64 minProcessingFeeLevel
Minimum fee level for a transaction to be considered for the open ledger or the queue.
Definition: TxQ.h:177
std::shared_ptr
STL class.
ripple::TxQ::getTxs
std::vector< TxDetails > getTxs(ReadView const &view) const
Returns information about all transactions currently in the queue.
Definition: TxQ.cpp:1781
ripple::TxQ::MaybeTx::txn
std::shared_ptr< STTx const > txn
The complete transaction.
Definition: TxQ.h:518
ripple::TxQ::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:732
ripple::TxQ::TxDetails::seqProxy
SeqProxy seqProxy
SeqProxy of the transaction.
Definition: TxQ.h:226
std::pair
ripple::TxQ::apply
std::pair< TER, bool > 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.
Definition: TxQ.cpp:726
ripple::TxQ::removeFromByFee
std::optional< TxQAccount::TxMap::iterator > removeFromByFee(std::optional< TxQAccount::TxMap::iterator > const &replacedTxIter, std::shared_ptr< STTx const > const &tx)
Definition: TxQ.cpp:1697
ripple::TxQ::FeeMetrics::FeeMetrics
FeeMetrics(Setup const &setup, beast::Journal j)
Constructor.
Definition: TxQ.h:398
ripple::OpenView
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:55
ripple::TxQ::MaybeTx::lastResult
std::optional< TER > lastResult
If the transactor attempted to apply the transaction to the open ledger from the queue and failed,...
Definition: TxQ.h:551
std::vector
STL class.
ripple::TxQ::TxQAccount
Used to represent an account to the queue, and stores the transactions queued for that account by Seq...
Definition: TxQ.h:634
std::map::size
T size(T... args)
ripple::TxQ::eraseAndAdvance
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_ (lo...
Definition: TxQ.cpp:453
ripple::TxQ::erase
FeeMultiSet::iterator_type erase(FeeMultiSet::const_iterator_type)
Erase and return the next entry in byFee_ (lower fee level)
ripple::TxQ::FeeMetrics
Track and use the fee escalation metrics of the current open ledger.
Definition: TxQ.h:373
ripple::ApplyFlags
ApplyFlags
Definition: ApplyView.h:29
ripple::FeeLevel64
FeeLevel< std::uint64_t > FeeLevel64
Definition: FeeUnits.h:464
ripple::TxQ::FeeMetrics::getSnapshot
Snapshot getSnapshot() const
Get the current Snapshot.
Definition: TxQ.h:451
ripple::TxQ::FeeMultiSet
boost::intrusive::multiset< MaybeTx, FeeHook, boost::intrusive::compare< GreaterFee > > FeeMultiSet
Definition: TxQ.h:725
std::lock_guard
STL class.
ripple::TxQ::TxDetails
Structure that describes a transaction in the queue waiting to be applied to the current open ledger.
Definition: TxQ.h:190
ripple::TxQ::nextQueuableSeqImpl
SeqProxy nextQueuableSeqImpl(std::shared_ptr< SLE const > const &sleAccount, std::lock_guard< std::mutex > const &) const
Definition: TxQ.cpp:1563
ripple::TxQ::TxQAccount::remove
bool remove(SeqProxy seqProx)
Remove the candidate with given SeqProxy value from this account.
Definition: TxQ.cpp:343
ripple::TxQ::MaybeTx::flags
const ApplyFlags flags
Flags provided to apply.
Definition: TxQ.h:544
ripple::TxQ::FeeMetrics::escalationMultiplier_
FeeLevel64 escalationMultiplier_
Based on the median fee of the LCL.
Definition: TxQ.h:392
ripple::TxQ::isFull
bool isFull() const
Is the queue at least fillPercentage full?
Definition: TxQ.cpp:362
ripple::TxQ::FeeAndSeq
Definition: TxQ.h:315
ripple::TxQ::canBeHeld
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.
Definition: TxQ.cpp:370
ripple::toFeeLevel
FeeLevel64 toFeeLevel(XRPAmount const &drops, XRPAmount const &baseFee)
Definition: TxQ.h:836
ripple::TxQ::FeeMetrics::maximumTxnCount_
const std::optional< std::size_t > maximumTxnCount_
Maximum value of txnsExpected.
Definition: TxQ.h:382
ripple::TxQ::FeeMetrics::recentTxnCounts_
boost::circular_buffer< std::size_t > recentTxnCounts_
Recent history of transaction counts that exceed the targetTxnCount_.
Definition: TxQ.h:389
ripple::TxQ::MaybeTx::apply
std::pair< TER, bool > apply(Application &app, OpenView &view, beast::Journal j)
Attempt to apply the queued transaction to the open ledger.
Definition: TxQ.cpp:289
ripple::TxQ::TxQAccount::transactions
TxMap transactions
Sequence number will be used as the key.
Definition: TxQ.h:642
ripple::TxQ::Metrics
Structure returned by TxQ::getMetrics, expressed in reference fee level units.
Definition: TxQ.h:160
ripple::TxQ::accept
bool accept(Application &app, OpenView &view)
Fill the new open ledger with transactions from the queue.
Definition: TxQ.cpp:1410
ripple::TxQ::Setup::maximumTxnPerAccount
std::uint32_t maximumTxnPerAccount
Maximum number of transactions that can be queued by one account.
Definition: TxQ.h:144
ripple::TxQ::FeeHook
boost::intrusive::member_hook< MaybeTx, boost::intrusive::set_member_hook<>, &MaybeTx::byFeeListHook > FeeHook
Definition: TxQ.h:722
ripple::TxQ::FeeMetrics::update
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.
Definition: TxQ.cpp:85
ripple::TxQ::MaybeTx::getTxDetails
TxDetails getTxDetails() const
Return a TxDetails based on contained information.
Definition: TxQ.h:601
ripple::TxQ::Setup::normalConsensusIncreasePercent
std::uint32_t normalConsensusIncreasePercent
When the ledger has more transactions than "expected", and performance is humming along nicely,...
Definition: TxQ.h:128
ripple::TxQ::MaybeTx::byFeeListHook
boost::intrusive::set_member_hook byFeeListHook
Used by the TxQ::FeeHook and TxQ::FeeMultiSet below to put each MaybeTx object into more than one set...
Definition: TxQ.h:515
ripple::TxQ::TxQAccount::retryPenalty
bool retryPenalty
Definition: TxQ.h:650
ripple::TxQ::MaybeTx::feeLevel
const FeeLevel64 feeLevel
Computed fee level that the transaction will pay.
Definition: TxQ.h:521
ripple::base_uint< 160, detail::AccountIDTag >
ripple::TxQ::Setup::targetTxnInLedger
std::uint32_t targetTxnInLedger
Number of transactions per ledger that fee escalation "works towards".
Definition: TxQ.h:105
ripple::toDrops
XRPAmount toDrops(FeeLevel< T > const &level, XRPAmount const &baseFee)
Definition: TxQ.h:827
ripple::TxQ::MaybeTx::MaybeTx
MaybeTx(std::shared_ptr< STTx const > const &, TxID const &txID, FeeLevel64 feeLevel, ApplyFlags const flags, PreflightResult const &pfresult)
Constructor.
Definition: TxQ.cpp:270
ripple::TxQ::Setup::standAlone
bool standAlone
Use standalone mode behavior.
Definition: TxQ.h:153
ripple::TxQ
Transaction Queue.
Definition: TxQ.h:56
ripple::TxQ::byFee_
FeeMultiSet byFee_
The queue itself: the collection of transactions ordered by fee level.
Definition: TxQ.h:744
ripple::PreflightResult
Describes the results of the preflight check.
Definition: applySteps.h:150
ripple::TxQ::GreaterFee
Used for sorting MaybeTx by feeLevel
Definition: TxQ.h:617
ripple::Config
Definition: Config.h:68
ripple::TxQ::TxDetails::account
AccountID account
The account the transaction is queued for.
Definition: TxQ.h:224
ripple::TxQ::feeMetrics_
FeeMetrics feeMetrics_
Tracks the current state of the queue.
Definition: TxQ.h:738
ripple::TxQ::Setup::minimumTxnInLedger
std::uint32_t minimumTxnInLedger
Minimum number of transactions to allow into the ledger before escalation, regardless of the prior le...
Definition: TxQ.h:99
ripple::TxQ::Setup
Structure used to customize TxQ behavior.
Definition: TxQ.h:65
ripple::TxQ::TxQAccount::account
const AccountID account
The account.
Definition: TxQ.h:640
ripple::TxQ::TxQAccount::getPrevTx
TxMap::const_iterator getPrevTx(SeqProxy seqProx) const
Find the entry in transactions that precedes seqProx, if one does.
Definition: TxQ.cpp:320
ripple::TERSubset
Definition: TER.h:327
ripple::TxQ::TxQAccount::add
MaybeTx & add(MaybeTx &&)
Add a transaction candidate to this account for queuing.
Definition: TxQ.cpp:331
ripple::TxQ::GreaterFee::operator()
bool operator()(const MaybeTx &lhs, const MaybeTx &rhs) const
Is the fee level of lhs greater than the fee level of rhs?
Definition: TxQ.h:625
ripple::TxQ::getTxRequiredFeeAndSeq
FeeAndSeq getTxRequiredFeeAndSeq(OpenView const &view, std::shared_ptr< STTx const > const &tx) const
Returns minimum required fee for tx and two sequences: first vaild sequence for this account in curre...
Definition: TxQ.cpp:1739
ripple::TxQ::MaybeTx::pfresult
std::optional< PreflightResult const > pfresult
Cached result of the preflight operation.
Definition: TxQ.h:560
ripple::TxQ::nextQueuableSeq
SeqProxy nextQueuableSeq(std::shared_ptr< SLE const > const &sleAccount) const
Return the next sequence that would go in the TxQ for an account.
Definition: TxQ.cpp:1550
ripple::TxQ::MaybeTx
Represents a transaction in the queue which may be applied later to the open ledger.
Definition: TxQ.h:509
ripple::TxQ::TxDetails::retriesRemaining
int retriesRemaining
Number of times the transactor can return a retry / ter result when attempting to apply this transact...
Definition: TxQ.h:234
ripple::STTx
Definition: STTx.h:42
ripple::TxQ::Setup::slowConsensusDecreasePercent
std::uint32_t slowConsensusDecreasePercent
When consensus takes longer than appropriate, the expected ledger size is updated to the lesser of th...
Definition: TxQ.h:142
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::TxQ::baseLevel
static constexpr FeeLevel64 baseLevel
Fee level for single-signed reference transaction.
Definition: TxQ.h:60
std::uint32_t
ripple::TxQ::FeeMetrics::scaleFeeLevel
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...
Definition: TxQ.cpp:170
ripple::feeunit::TaggedFee
Definition: FeeUnits.h:70
std::map< SeqProxy, MaybeTx >
ripple::TxQ::FeeMetrics::minimumTxnCount_
const std::size_t minimumTxnCount_
Minimum value of txnsExpected.
Definition: TxQ.h:377
ripple::TxQ::FeeAndSeq::accountSeq
std::uint32_t accountSeq
Definition: TxQ.h:318
ripple::TxQ::processClosedLedger
void processClosedLedger(Application &app, ReadView const &view, bool timeLeap)
Update fee metrics and clean up the queue in preparation for the next ledger.
Definition: TxQ.cpp:1341
ripple::TxQ::MaybeTx::seqProxy
const SeqProxy seqProxy
Transaction SeqProxy number (sfSequence or sfTicketSequence field).
Definition: TxQ.h:531
ripple::TxQ::doRPC
Json::Value doRPC(Application &app) const
Summarize current fee metrics for the fee RPC command.
Definition: TxQ.cpp:1796
ripple::TxQ::FeeMetrics::targetTxnCount_
const std::size_t targetTxnCount_
Number of transactions per ledger that fee escalation "works towards".
Definition: TxQ.h:380
ripple::TxQ::MaybeTx::consequences
TxConsequences const & consequences() const
Potential TxConsequences of applying this transaction to the open ledger.
Definition: TxQ.h:594
ripple::TxQ::TxQAccount::dropPenalty
bool dropPenalty
Definition: TxQ.h:656
ripple::TxQ::Metrics::referenceFeeLevel
FeeLevel64 referenceFeeLevel
Reference transaction fee level.
Definition: TxQ.h:174
ripple::TxQ::TxDetails::consequences
TxConsequences consequences
Potential TxConsequences of applying the queued transaction to the open ledger.
Definition: TxQ.h:222
ripple::TxQ::~TxQ
virtual ~TxQ()
Destructor.
Definition: TxQ.cpp:355
ripple::TxQ::TxQAccount::empty
bool empty() const
Checks if this account has no transactions queued.
Definition: TxQ.h:673
ripple::TxQ::Metrics::medFeeLevel
FeeLevel64 medFeeLevel
Median fee level of the last ledger.
Definition: TxQ.h:179
ripple::TxQ::FeeMetrics::Snapshot
Snapshot of the externally relevant FeeMetrics fields at any given time.
Definition: TxQ.h:438
ripple::TxQ::FeeMetrics::Snapshot::escalationMultiplier
const FeeLevel64 escalationMultiplier
Definition: TxQ.h:446
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:192
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::TxQ::TxQ
TxQ(Setup const &setup, beast::Journal j)
Constructor.
Definition: TxQ.cpp:350
ripple::TxQ::TxQAccount::getTxnCount
std::size_t getTxnCount() const
Return the number of transactions currently queued for this account.
Definition: TxQ.h:666
ripple::TxQ::getRequiredFeeLevel
FeeLevel64 getRequiredFeeLevel(OpenView &view, ApplyFlags flags, FeeMetrics::Snapshot const &metricsSnapshot, std::lock_guard< std::mutex > const &lock) const
Definition: TxQ.cpp:1610
ripple::TxQ::MaybeTx::account
const AccountID account
Account submitting the transaction.
Definition: TxQ.h:525
ripple::TxQ::Setup::Setup
Setup()=default
Default constructor.
std
STL namespace.
ripple::TxQ::Metrics::txInLedger
std::size_t txInLedger
Number of transactions currently in the open ledger.
Definition: TxQ.h:170
ripple::TxQ::GreaterFee::GreaterFee
GreaterFee()=default
Default constructor.
ripple::TxQ::mutex_
std::mutex mutex_
Most queue operations are done under the master lock, but use this mutex for the RPC "fee" command,...
Definition: TxQ.h:763
ripple::TxQ::maxSize_
std::optional< size_t > maxSize_
Maximum number of transactions allowed in the queue based on the current metrics.
Definition: TxQ.h:758
ripple::SeqProxy
A type that represents either a sequence value or a ticket value.
Definition: SeqProxy.h:55
ripple::TxQ::MaybeTx::retriesAllowed
static constexpr int retriesAllowed
Starting retry count for newly queued transactions.
Definition: TxQ.h:576
ripple::TxQ::FeeMetrics::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:394
ripple::TxQ::Metrics::txCount
std::size_t txCount
Number of transactions in the queue.
Definition: TxQ.h:166
ripple::TxQ::TxDetails::TxDetails
TxDetails(FeeLevel64 feeLevel_, std::optional< LedgerIndex > const &lastValid_, TxConsequences const &consequences_, AccountID const &account_, SeqProxy seqProxy_, std::shared_ptr< STTx const > const &txn_, int retriesRemaining_, TER preflightResult_, std::optional< TER > lastResult_)
Full initialization.
Definition: TxQ.h:193
ripple::TxQ::Setup::retrySequencePercent
std::uint32_t retrySequencePercent
Extra percentage required on the fee level of a queued transaction to replace that transaction with a...
Definition: TxQ.h:93
optional
std::mutex
STL class.
ripple::TxQ::Setup::minimumTxnInLedgerSA
std::uint32_t minimumTxnInLedgerSA
Like minimumTxnInLedger for standalone mode.
Definition: TxQ.h:102
std::size_t
ripple::TxQ::TxDetails::preflightResult
TER preflightResult
The intermediate result returned by preflight before this transaction was queued, or after it is queu...
Definition: TxQ.h:244
ripple::TxQ::TxQAccount::TxQAccount
TxQAccount(std::shared_ptr< STTx const > const &txn)
Construct from a transaction.
Definition: TxQ.cpp:310
ripple::mulDiv
std::pair< bool, Dest > mulDiv(Source1 value, Dest mul, Source2 div)
Definition: FeeUnits.h:473
ripple::TxQ::tryDirectApply
std::optional< std::pair< TER, bool > > tryDirectApply(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, ApplyFlags flags, beast::Journal j)
Definition: TxQ.cpp:1626
ripple::TxQ::TxDetails::feeLevel
FeeLevel64 feeLevel
Fee level of the queued transaction.
Definition: TxQ.h:216
ripple::STAmount::cMaxNativeN
static const std::uint64_t cMaxNativeN
Definition: STAmount.h:69
ripple::TxQ::Setup::maximumTxnInLedger
std::optional< std::uint32_t > maximumTxnInLedger
Optional maximum allowed value of transactions per ledger before fee escalation kicks in.
Definition: TxQ.h:116
ripple::TxQ::Metrics::openLedgerFeeLevel
FeeLevel64 openLedgerFeeLevel
Minimum fee level to get into the current open ledger, bypassing the queue.
Definition: TxQ.h:182
ripple::TxQ::Metrics::txQMaxSize
std::optional< std::size_t > txQMaxSize
Max transactions currently allowed in queue.
Definition: TxQ.h:168
ripple::TxQ::Setup::queueSizeMin
std::size_t queueSizeMin
The smallest limit the queue is allowed.
Definition: TxQ.h:83
ripple::TxQ::getAccountTxs
std::vector< TxDetails > getAccountTxs(AccountID const &account, ReadView const &view) const
Returns information about the transactions currently in the queue for the account.
Definition: TxQ.cpp:1760
ripple::TxQ::byAccount_
AccountMap byAccount_
All of the accounts which currently have any transactions in the queue.
Definition: TxQ.h:751
ripple::TxQ::getMetrics
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
Definition: TxQ.cpp:1717
ripple::TxQ::FeeMetrics::txnsExpected_
std::size_t txnsExpected_
Number of transactions expected per ledger.
Definition: TxQ.h:386
ripple::TxQ::Setup::minimumEscalationMultiplier
FeeLevel64 minimumEscalationMultiplier
Minimum value of the escalation multiplier, regardless of the prior ledger's median fee level.
Definition: TxQ.h:96
ripple::TxQ::MaybeTx::retriesRemaining
int retriesRemaining
A transaction at the front of the queue will be given several attempts to succeed before being droppe...
Definition: TxQ.h:540
ripple::TxQ::Setup::minimumLastLedgerBuffer
std::uint32_t minimumLastLedgerBuffer
Minimum difference between the current ledger sequence and a transaction's LastLedgerSequence for the...
Definition: TxQ.h:151
ripple::TxQ::MaybeTx::txID
const TxID txID
Transaction ID.
Definition: TxQ.h:523
ripple::TxQ::TxDetails::lastResult
std::optional< TER > lastResult
If the transactor attempted to apply the transaction to the open ledger from the queue and failed,...
Definition: TxQ.h:251
ripple::TxQ::FeeMetrics::escalatedSeriesFeeLevel
static std::pair< bool, FeeLevel64 > escalatedSeriesFeeLevel(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.
Definition: TxQ.cpp:230
ripple::TxQ::Setup::ledgersInQueue
std::size_t ledgersInQueue
Number of ledgers' worth of transactions to allow in the queue.
Definition: TxQ.h:77
ripple::TxQ::MaybeTx::lastValid
const std::optional< LedgerIndex > lastValid
Expiration ledger for the transaction (sfLastLedgerSequence field).
Definition: TxQ.h:528
ripple::TxQ::FeeAndSeq::availableSeq
std::uint32_t availableSeq
Definition: TxQ.h:319
ripple::TxConsequences
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition: applySteps.h:45
std::numeric_limits
ripple::TxQ::FeeMetrics::Snapshot::txnsExpected
const std::size_t txnsExpected
Definition: TxQ.h:443
ripple::TxQ::TxDetails::txn
std::shared_ptr< STTx const > txn
The full transaction.
Definition: TxQ.h:228
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::TxQ::FeeAndSeq::fee
XRPAmount fee
Definition: TxQ.h:317
ripple::TxQ::Metrics::txPerLedger
std::size_t txPerLedger
Number of transactions expected per ledger.
Definition: TxQ.h:172