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/RippleLedgerHash.h>
27 #include <ripple/protocol/STTx.h>
28 #include <ripple/protocol/SeqProxy.h>
29 #include <ripple/protocol/TER.h>
30 #include <boost/circular_buffer.hpp>
31 #include <boost/intrusive/set.hpp>
32 #include <optional>
33 
34 namespace ripple {
35 
36 class Application;
37 class Config;
38 
57 class TxQ
58 {
59 public:
61  static constexpr FeeLevel64 baseLevel{256};
62 
66  struct Setup
67  {
69  explicit Setup() = default;
70 
154  bool standAlone = false;
155  };
156 
161  struct Metrics
162  {
164  explicit Metrics() = default;
165 
184  };
185 
191  struct TxDetails
192  {
195  FeeLevel64 feeLevel_,
196  std::optional<LedgerIndex> const& lastValid_,
197  TxConsequences const& consequences_,
198  AccountID const& account_,
199  SeqProxy seqProxy_,
200  std::shared_ptr<STTx const> const& txn_,
201  int retriesRemaining_,
202  TER preflightResult_,
203  std::optional<TER> lastResult_)
204  : feeLevel(feeLevel_)
205  , lastValid(lastValid_)
206  , consequences(consequences_)
207  , account(account_)
208  , seqProxy(seqProxy_)
209  , txn(txn_)
210  , retriesRemaining(retriesRemaining_)
211  , preflightResult(preflightResult_)
212  , lastResult(lastResult_)
213  {
214  }
215 
253  };
254 
256  TxQ(Setup const& setup, beast::Journal j);
257 
259  virtual ~TxQ();
260 
271  apply(
272  Application& app,
273  OpenView& view,
274  std::shared_ptr<STTx const> const& tx,
275  ApplyFlags flags,
276  beast::Journal j);
277 
289  bool
290  accept(Application& app, OpenView& view);
291 
304  void
305  processClosedLedger(Application& app, ReadView const& view, bool timeLeap);
306 
308  SeqProxy
309  nextQueuableSeq(std::shared_ptr<SLE const> const& sleAccount) const;
310 
313  Metrics
314  getMetrics(OpenView const& view) const;
315 
316  struct FeeAndSeq
317  {
321  };
322 
332  FeeAndSeq
334  OpenView const& view,
335  std::shared_ptr<STTx const> const& tx) const;
336 
344  getAccountTxs(AccountID const& account) const;
345 
353  getTxs() const;
354 
360  doRPC(Application& app) const;
361 
362 private:
363  // Implementation for nextQueuableSeq(). The passed lock must be held.
364  SeqProxy
366  std::shared_ptr<SLE const> const& sleAccount,
367  std::lock_guard<std::mutex> const&) const;
368 
375  {
376  private:
390  boost::circular_buffer<std::size_t> recentTxnCounts_;
396 
397  public:
399  FeeMetrics(Setup const& setup, beast::Journal j)
401  setup.standAlone ? setup.minimumTxnInLedgerSA
402  : setup.minimumTxnInLedger)
403  , targetTxnCount_(
404  setup.targetTxnInLedger < minimumTxnCount_
406  : setup.targetTxnInLedger)
408  setup.maximumTxnInLedger
409  ? *setup.maximumTxnInLedger < targetTxnCount_
411  : *setup.maximumTxnInLedger
412  : std::optional<std::size_t>(std::nullopt))
414  , recentTxnCounts_(setup.ledgersInQueue)
415  , escalationMultiplier_(setup.minimumEscalationMultiplier)
416  , j_(j)
417  {
418  }
419 
431  update(
432  Application& app,
433  ReadView const& view,
434  bool timeLeap,
435  TxQ::Setup const& setup);
436 
439  struct Snapshot
440  {
441  // Number of transactions expected per ledger.
442  // One more than this value will be accepted
443  // before escalation kicks in.
445  // Based on the median fee of the LCL. Used
446  // when fee escalation kicks in.
448  };
449 
451  Snapshot
452  getSnapshot() const
453  {
455  }
456 
465  static FeeLevel64
466  scaleFeeLevel(Snapshot const& snapshot, OpenView const& view);
467 
500  Snapshot const& snapshot,
501  OpenView const& view,
502  std::size_t extraCount,
503  std::size_t seriesSize);
504  };
505 
510  class MaybeTx
511  {
512  public:
516  boost::intrusive::set_member_hook<> byFeeListHook;
517 
520 
524  TxID const txID;
562 
577  static constexpr int retriesAllowed = 10;
578 
588 
589  public:
591  MaybeTx(
593  TxID const& txID,
595  ApplyFlags const flags,
596  PreflightResult const& pfresult);
597 
600  apply(Application& app, OpenView& view, beast::Journal j);
601 
604  TxConsequences const&
605  consequences() const
606  {
607  return pfresult->consequences;
608  }
609 
611  TxDetails
612  getTxDetails() const
613  {
614  return {
615  feeLevel,
616  lastValid,
617  consequences(),
618  account,
619  seqProxy,
620  txn,
622  pfresult->ter,
623  lastResult};
624  }
625  };
626 
629  {
630  public:
632  explicit OrderCandidates() = default;
633 
649  bool
650  operator()(const MaybeTx& lhs, const MaybeTx& rhs) const
651  {
652  if (lhs.feeLevel == rhs.feeLevel)
653  return (lhs.txID ^ MaybeTx::parentHashComp) <
655  return lhs.feeLevel > rhs.feeLevel;
656  }
657  };
658 
663  {
664  public:
666 
671  /* If this account has had any transaction retry more than
672  `retriesAllowed` times so that it was dropped from the
673  queue, then all other transactions for this account will
674  be given at most 2 attempts before being removed. Helps
675  prevent wasting resources on retries that are more likely
676  to fail.
677  */
678  bool retryPenalty = false;
679  /* If this account has had any transaction fail or expire,
680  then when the queue is nearly full, transactions from
681  this account will be discarded. Helps prevent the queue
682  from getting filled and wedged.
683  */
684  bool dropPenalty = false;
685 
686  public:
688  explicit TxQAccount(std::shared_ptr<STTx const> const& txn);
690  explicit TxQAccount(const AccountID& account);
691 
694  getTxnCount() const
695  {
696  return transactions.size();
697  }
698 
700  bool
701  empty() const
702  {
703  return !getTxnCount();
704  }
705 
707  TxMap::const_iterator
708  getPrevTx(SeqProxy seqProx) const;
709 
711  MaybeTx&
712  add(MaybeTx&&);
713 
719  bool
720  remove(SeqProxy seqProx);
721  };
722 
723  // Helper function returns requiredFeeLevel.
724  FeeLevel64
726  OpenView& view,
727  ApplyFlags flags,
728  FeeMetrics::Snapshot const& metricsSnapshot,
729  std::lock_guard<std::mutex> const& lock) const;
730 
731  // Helper function for TxQ::apply. If a transaction's fee is high enough,
732  // attempt to directly apply that transaction to the ledger.
735  Application& app,
736  OpenView& view,
737  std::shared_ptr<STTx const> const& tx,
738  ApplyFlags flags,
739  beast::Journal j);
740 
741  // Helper function that removes a replaced entry in _byFee.
744  std::optional<TxQAccount::TxMap::iterator> const& replacedTxIter,
745  std::shared_ptr<STTx const> const& tx);
746 
747  using FeeHook = boost::intrusive::member_hook<
748  MaybeTx,
749  boost::intrusive::set_member_hook<>,
751 
752  using FeeMultiSet = boost::intrusive::
753  multiset<MaybeTx, FeeHook, boost::intrusive::compare<OrderCandidates>>;
754 
756 
758  Setup const setup_;
761 
787 
788 #if !NDEBUG
789 
793  LedgerHash parentHash_{beast::zero};
794 #endif
795 
800 
801 private:
803  template <size_t fillPercentage = 100>
804  bool
805  isFull() const;
806 
810  TER
811  canBeHeld(
812  STTx const&,
813  ApplyFlags const,
814  OpenView const&,
815  std::shared_ptr<SLE const> const& sleAccount,
816  AccountMap::iterator const&,
818  std::lock_guard<std::mutex> const& lock);
819 
821  FeeMultiSet::iterator_type erase(FeeMultiSet::const_iterator_type);
826  FeeMultiSet::iterator_type eraseAndAdvance(
827  FeeMultiSet::const_iterator_type);
829  TxQAccount::TxMap::iterator
830  erase(
831  TxQAccount& txQAccount,
832  TxQAccount::TxMap::const_iterator begin,
833  TxQAccount::TxMap::const_iterator end);
834 
842  Application& app,
843  OpenView& view,
844  STTx const& tx,
845  AccountMap::iterator const& accountIter,
846  TxQAccount::TxMap::iterator,
847  FeeLevel64 feeLevelPaid,
848  PreflightResult const& pfresult,
849  std::size_t const txExtraCount,
850  ApplyFlags flags,
851  FeeMetrics::Snapshot const& metricsSnapshot,
852  beast::Journal j);
853 };
854 
859 setup_TxQ(Config const&);
860 
861 template <class T>
862 XRPAmount
863 toDrops(FeeLevel<T> const& level, XRPAmount baseFee)
864 {
865  if (auto const drops = mulDiv(level, baseFee, TxQ::baseLevel); drops.first)
866  return drops.second;
867 
869 }
870 
871 inline FeeLevel64
872 toFeeLevel(XRPAmount const& drops, XRPAmount const& baseFee)
873 {
874  if (auto const feeLevel = mulDiv(drops, TxQ::baseLevel, baseFee);
875  feeLevel.first)
876  return feeLevel.second;
877 
879 }
880 
881 } // namespace ripple
882 
883 #endif
ripple::TxQ::setup_
const Setup setup_
Setup parameters used to control the behavior of the queue.
Definition: TxQ.h:758
ripple::setup_TxQ
TxQ::Setup setup_TxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
Definition: TxQ.cpp:1881
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:503
ripple::Application
Definition: Application.h:115
ripple::TxQ::parentHash_
LedgerHash parentHash_
parentHash_ checks that no unexpected ledger transitions happen, and is only checked via debug assert...
Definition: TxQ.h:793
ripple::TxQ::TxDetails::lastValid
std::optional< LedgerIndex > lastValid
LastValidLedger field of the queued transaction, if any.
Definition: TxQ.h:219
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:178
std::shared_ptr
STL class.
ripple::TxQ::MaybeTx::txn
std::shared_ptr< STTx const > txn
The complete transaction.
Definition: TxQ.h:519
ripple::TxQ::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:760
ripple::TxQ::TxDetails::seqProxy
SeqProxy seqProxy
SeqProxy of the transaction.
Definition: TxQ.h:227
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:713
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:1727
ripple::TxQ::FeeMetrics::FeeMetrics
FeeMetrics(Setup const &setup, beast::Journal j)
Constructor.
Definition: TxQ.h:399
ripple::TxQ::OrderCandidates::OrderCandidates
OrderCandidates()=default
Default constructor.
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:552
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:662
ripple::TxQ::getTxs
std::vector< TxDetails > getTxs() const
Returns information about all transactions currently in the queue.
Definition: TxQ.cpp:1811
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:456
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:374
ripple::ApplyFlags
ApplyFlags
Definition: ApplyView.h:29
ripple::FeeLevel64
FeeLevel< std::uint64_t > FeeLevel64
Definition: FeeUnits.h:459
ripple::TxQ::FeeMetrics::getSnapshot
Snapshot getSnapshot() const
Get the current Snapshot.
Definition: TxQ.h:452
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:191
ripple::TxQ::nextQueuableSeqImpl
SeqProxy nextQueuableSeqImpl(std::shared_ptr< SLE const > const &sleAccount, std::lock_guard< std::mutex > const &) const
Definition: TxQ.cpp:1599
ripple::TxQ::TxQAccount::remove
bool remove(SeqProxy seqProx)
Remove the candidate with given SeqProxy value from this account.
Definition: TxQ.cpp:346
ripple::TxQ::MaybeTx::flags
const ApplyFlags flags
Flags provided to apply.
Definition: TxQ.h:545
ripple::TxQ::FeeMetrics::escalationMultiplier_
FeeLevel64 escalationMultiplier_
Based on the median fee of the LCL.
Definition: TxQ.h:393
ripple::TxQ::isFull
bool isFull() const
Is the queue at least fillPercentage full?
Definition: TxQ.cpp:365
ripple::TxQ::FeeAndSeq
Definition: TxQ.h:316
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:373
ripple::toFeeLevel
FeeLevel64 toFeeLevel(XRPAmount const &drops, XRPAmount const &baseFee)
Definition: TxQ.h:872
ripple::TxQ::FeeMetrics::maximumTxnCount_
const std::optional< std::size_t > maximumTxnCount_
Maximum value of txnsExpected.
Definition: TxQ.h:383
ripple::TxQ::FeeMetrics::recentTxnCounts_
boost::circular_buffer< std::size_t > recentTxnCounts_
Recent history of transaction counts that exceed the targetTxnCount_.
Definition: TxQ.h:390
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:291
ripple::TxQ::TxQAccount::transactions
TxMap transactions
Sequence number will be used as the key.
Definition: TxQ.h:670
ripple::TxQ::Metrics
Structure returned by TxQ::getMetrics, expressed in reference fee level units.
Definition: TxQ.h:161
ripple::TxQ::accept
bool accept(Application &app, OpenView &view)
Fill the new open ledger with transactions from the queue.
Definition: TxQ.cpp:1415
ripple::TxQ::Setup::maximumTxnPerAccount
std::uint32_t maximumTxnPerAccount
Maximum number of transactions that can be queued by one account.
Definition: TxQ.h:145
ripple::TxQ::FeeHook
boost::intrusive::member_hook< MaybeTx, boost::intrusive::set_member_hook<>, &MaybeTx::byFeeListHook > FeeHook
Definition: TxQ.h:750
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:86
ripple::TxQ::MaybeTx::getTxDetails
TxDetails getTxDetails() const
Return a TxDetails based on contained information.
Definition: TxQ.h:612
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:129
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:516
ripple::TxQ::TxQAccount::retryPenalty
bool retryPenalty
Definition: TxQ.h:678
ripple::TxQ::MaybeTx::feeLevel
const FeeLevel64 feeLevel
Computed fee level that the transaction will pay.
Definition: TxQ.h:522
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:106
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:272
ripple::TxQ::Setup::standAlone
bool standAlone
Use standalone mode behavior.
Definition: TxQ.h:154
ripple::TxQ
Transaction Queue.
Definition: TxQ.h:57
ripple::TxQ::byFee_
FeeMultiSet byFee_
The queue itself: the collection of transactions ordered by fee level.
Definition: TxQ.h:772
ripple::PreflightResult
Describes the results of the preflight check.
Definition: applySteps.h:150
ripple::TxQ::getAccountTxs
std::vector< TxDetails > getAccountTxs(AccountID const &account) const
Returns information about the transactions currently in the queue for the account.
Definition: TxQ.cpp:1790
ripple::Config
Definition: Config.h:89
ripple::TxQ::TxDetails::account
AccountID account
The account the transaction is queued for.
Definition: TxQ.h:225
ripple::TxQ::feeMetrics_
FeeMetrics feeMetrics_
Tracks the current state of the queue.
Definition: TxQ.h:766
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:100
ripple::TxQ::Setup
Structure used to customize TxQ behavior.
Definition: TxQ.h:66
ripple::TxQ::TxQAccount::account
const AccountID account
The account.
Definition: TxQ.h:668
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:323
ripple::TERSubset< CanCvtToTER >
ripple::TxQ::FeeMultiSet
boost::intrusive::multiset< MaybeTx, FeeHook, boost::intrusive::compare< OrderCandidates > > FeeMultiSet
Definition: TxQ.h:753
ripple::TxQ::TxQAccount::add
MaybeTx & add(MaybeTx &&)
Add a transaction candidate to this account for queuing.
Definition: TxQ.cpp:334
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:1769
ripple::TxQ::MaybeTx::pfresult
std::optional< PreflightResult const > pfresult
Cached result of the preflight operation.
Definition: TxQ.h:561
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:1586
ripple::TxQ::MaybeTx
Represents a transaction in the queue which may be applied later to the open ledger.
Definition: TxQ.h:510
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:235
ripple::STTx
Definition: STTx.h:45
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:143
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:61
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:378
ripple::TxQ::FeeAndSeq::accountSeq
std::uint32_t accountSeq
Definition: TxQ.h:319
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:1346
ripple::TxQ::MaybeTx::seqProxy
const SeqProxy seqProxy
Transaction SeqProxy number (sfSequence or sfTicketSequence field).
Definition: TxQ.h:532
ripple::TxQ::doRPC
Json::Value doRPC(Application &app) const
Summarize current fee metrics for the fee RPC command.
Definition: TxQ.cpp:1826
ripple::TxQ::FeeMetrics::targetTxnCount_
const std::size_t targetTxnCount_
Number of transactions per ledger that fee escalation "works towards".
Definition: TxQ.h:381
ripple::TxQ::MaybeTx::consequences
TxConsequences const & consequences() const
Potential TxConsequences of applying this transaction to the open ledger.
Definition: TxQ.h:605
ripple::TxQ::TxQAccount::dropPenalty
bool dropPenalty
Definition: TxQ.h:684
ripple::TxQ::Metrics::referenceFeeLevel
FeeLevel64 referenceFeeLevel
Reference transaction fee level.
Definition: TxQ.h:175
ripple::TxQ::TxDetails::consequences
TxConsequences consequences
Potential TxConsequences of applying the queued transaction to the open ledger.
Definition: TxQ.h:223
ripple::TxQ::~TxQ
virtual ~TxQ()
Destructor.
Definition: TxQ.cpp:358
ripple::TxQ::TxQAccount::empty
bool empty() const
Checks if this account has no transactions queued.
Definition: TxQ.h:701
ripple::TxQ::Metrics::medFeeLevel
FeeLevel64 medFeeLevel
Median fee level of the last ledger.
Definition: TxQ.h:180
ripple::TxQ::FeeMetrics::Snapshot
Snapshot of the externally relevant FeeMetrics fields at any given time.
Definition: TxQ.h:439
ripple::TxQ::FeeMetrics::Snapshot::escalationMultiplier
const FeeLevel64 escalationMultiplier
Definition: TxQ.h:447
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:125
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:353
ripple::TxQ::TxQAccount::getTxnCount
std::size_t getTxnCount() const
Return the number of transactions currently queued for this account.
Definition: TxQ.h:694
ripple::TxQ::getRequiredFeeLevel
FeeLevel64 getRequiredFeeLevel(OpenView &view, ApplyFlags flags, FeeMetrics::Snapshot const &metricsSnapshot, std::lock_guard< std::mutex > const &lock) const
Definition: TxQ.cpp:1646
ripple::TxQ::MaybeTx::account
const AccountID account
Account submitting the transaction.
Definition: TxQ.h:526
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:171
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:799
ripple::TxQ::maxSize_
std::optional< size_t > maxSize_
Maximum number of transactions allowed in the queue based on the current metrics.
Definition: TxQ.h:786
ripple::SeqProxy
A type that represents either a sequence value or a ticket value.
Definition: SeqProxy.h:55
ripple::TxQ::MaybeTx::parentHashComp
static LedgerHash parentHashComp
The hash of the parent ledger.
Definition: TxQ.h:587
ripple::TxQ::MaybeTx::retriesAllowed
static constexpr int retriesAllowed
Starting retry count for newly queued transactions.
Definition: TxQ.h:577
ripple::TxQ::FeeMetrics::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:395
ripple::TxQ::Metrics::txCount
std::size_t txCount
Number of transactions in the queue.
Definition: TxQ.h:167
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:194
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:94
optional
std::mutex
STL class.
ripple::TxQ::Setup::minimumTxnInLedgerSA
std::uint32_t minimumTxnInLedgerSA
Like minimumTxnInLedger for standalone mode.
Definition: TxQ.h:103
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:245
ripple::TxQ::OrderCandidates
Used for sorting MaybeTx.
Definition: TxQ.h:628
ripple::TxQ::TxQAccount::TxQAccount
TxQAccount(std::shared_ptr< STTx const > const &txn)
Construct from a transaction.
Definition: TxQ.cpp:313
ripple::mulDiv
std::pair< bool, Dest > mulDiv(Source1 value, Dest mul, Source2 div)
Definition: FeeUnits.h:468
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:1656
ripple::TxQ::TxDetails::feeLevel
FeeLevel64 feeLevel
Fee level of the queued transaction.
Definition: TxQ.h:217
ripple::STAmount::cMaxNativeN
static const std::uint64_t cMaxNativeN
Definition: STAmount.h:71
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:117
ripple::TxQ::Metrics::openLedgerFeeLevel
FeeLevel64 openLedgerFeeLevel
Minimum fee level to get into the current open ledger, bypassing the queue.
Definition: TxQ.h:183
ripple::TxQ::Metrics::txQMaxSize
std::optional< std::size_t > txQMaxSize
Max transactions currently allowed in queue.
Definition: TxQ.h:169
ripple::TxQ::Setup::queueSizeMin
std::size_t queueSizeMin
The smallest limit the queue is allowed.
Definition: TxQ.h:84
ripple::TxQ::byAccount_
AccountMap byAccount_
All of the accounts which currently have any transactions in the queue.
Definition: TxQ.h:779
ripple::TxQ::getMetrics
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
Definition: TxQ.cpp:1747
ripple::TxQ::FeeMetrics::txnsExpected_
std::size_t txnsExpected_
Number of transactions expected per ledger.
Definition: TxQ.h:387
ripple::TxQ::Setup::minimumEscalationMultiplier
FeeLevel64 minimumEscalationMultiplier
Minimum value of the escalation multiplier, regardless of the prior ledger's median fee level.
Definition: TxQ.h:97
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:541
ripple::TxQ::OrderCandidates::operator()
bool operator()(const MaybeTx &lhs, const MaybeTx &rhs) const
Sort MaybeTx by feeLevel descending, then by pseudo-randomized transaction ID ascending.
Definition: TxQ.h:650
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:152
ripple::TxQ::MaybeTx::txID
const TxID txID
Transaction ID.
Definition: TxQ.h:524
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:252
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:78
ripple::TxQ::MaybeTx::lastValid
const std::optional< LedgerIndex > lastValid
Expiration ledger for the transaction (sfLastLedgerSequence field).
Definition: TxQ.h:529
ripple::TxQ::FeeAndSeq::availableSeq
std::uint32_t availableSeq
Definition: TxQ.h:320
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::toDrops
XRPAmount toDrops(FeeLevel< T > const &level, XRPAmount baseFee)
Definition: TxQ.h:863
ripple::TxQ::FeeMetrics::Snapshot::txnsExpected
const std::size_t txnsExpected
Definition: TxQ.h:444
ripple::TxQ::TxDetails::txn
std::shared_ptr< STTx const > txn
The full transaction.
Definition: TxQ.h:229
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:318
ripple::TxQ::Metrics::txPerLedger
std::size_t txPerLedger
Number of transactions expected per ledger.
Definition: TxQ.h:173