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 
32 namespace ripple {
33 
34 class Application;
35 class Config;
36 
55 class TxQ
56 {
57 public:
59  static constexpr FeeLevel64 baseLevel{256};
60 
64  struct Setup
65  {
67  explicit Setup() = default;
68 
115  boost::optional<std::uint32_t> maximumTxnInLedger;
152  bool standAlone = false;
153  };
154 
159  struct Metrics
160  {
162  explicit Metrics() = default;
163 
167  boost::optional<std::size_t> txQMaxSize;
182  };
183 
189  struct TxDetails
190  {
193  FeeLevel64 feeLevel_,
194  boost::optional<LedgerIndex> const& lastValid_,
195  TxConsequences const& consequences_,
196  AccountID const& account_,
197  SeqProxy seqProxy_,
198  std::shared_ptr<STTx const> const& txn_,
199  int retriesRemaining_,
200  TER preflightResult_,
201  boost::optional<TER> lastResult_)
202  : feeLevel(feeLevel_)
203  , lastValid(lastValid_)
204  , consequences(consequences_)
205  , account(account_)
206  , seqProxy(seqProxy_)
207  , txn(txn_)
208  , retriesRemaining(retriesRemaining_)
209  , preflightResult(preflightResult_)
210  , lastResult(lastResult_)
211  {
212  }
213 
217  boost::optional<LedgerIndex> lastValid;
250  boost::optional<TER> lastResult;
251  };
252 
254  TxQ(Setup const& setup, beast::Journal j);
255 
257  virtual ~TxQ();
258 
269  apply(
270  Application& app,
271  OpenView& view,
272  std::shared_ptr<STTx const> const& tx,
273  ApplyFlags flags,
274  beast::Journal j);
275 
287  bool
288  accept(Application& app, OpenView& view);
289 
302  void
303  processClosedLedger(Application& app, ReadView const& view, bool timeLeap);
304 
306  SeqProxy
307  nextQueuableSeq(std::shared_ptr<SLE const> const& sleAccount) const;
308 
311  Metrics
312  getMetrics(OpenView const& view) const;
313 
314  struct FeeAndSeq
315  {
319  };
320 
330  FeeAndSeq
332  OpenView const& view,
333  std::shared_ptr<STTx const> const& tx) const;
334 
342  getAccountTxs(AccountID const& account, ReadView const& view) const;
343 
351  getTxs(ReadView const& view) const;
352 
358  doRPC(Application& app) const;
359 
360 private:
361  // Implementation for nextQueuableSeq(). The passed lock must be held.
362  SeqProxy
364  std::shared_ptr<SLE const> const& sleAccount,
365  std::lock_guard<std::mutex> const&) const;
366 
373  {
374  private:
381  boost::optional<std::size_t> const maximumTxnCount_;
388  boost::circular_buffer<std::size_t> recentTxnCounts_;
394 
395  public:
397  FeeMetrics(Setup const& setup, beast::Journal j)
399  setup.standAlone ? setup.minimumTxnInLedgerSA
400  : setup.minimumTxnInLedger)
401  , targetTxnCount_(
402  setup.targetTxnInLedger < minimumTxnCount_
404  : setup.targetTxnInLedger)
406  setup.maximumTxnInLedger
407  ? *setup.maximumTxnInLedger < targetTxnCount_
409  : *setup.maximumTxnInLedger
410  : boost::optional<std::size_t>(boost::none))
412  , recentTxnCounts_(setup.ledgersInQueue)
413  , escalationMultiplier_(setup.minimumEscalationMultiplier)
414  , j_(j)
415  {
416  }
417 
429  update(
430  Application& app,
431  ReadView const& view,
432  bool timeLeap,
433  TxQ::Setup const& setup);
434 
437  struct Snapshot
438  {
439  // Number of transactions expected per ledger.
440  // One more than this value will be accepted
441  // before escalation kicks in.
443  // Based on the median fee of the LCL. Used
444  // when fee escalation kicks in.
446  };
447 
449  Snapshot
450  getSnapshot() const
451  {
453  }
454 
463  static FeeLevel64
464  scaleFeeLevel(Snapshot const& snapshot, OpenView const& view);
465 
498  Snapshot const& snapshot,
499  OpenView const& view,
500  std::size_t extraCount,
501  std::size_t seriesSize);
502  };
503 
508  class MaybeTx
509  {
510  public:
514  boost::intrusive::set_member_hook<> byFeeListHook;
515 
518 
522  TxID const txID;
527  boost::optional<LedgerIndex> const lastValid;
550  boost::optional<TER> lastResult;
559  boost::optional<PreflightResult const> pfresult;
560 
575  static constexpr int retriesAllowed = 10;
576 
577  public:
579  MaybeTx(
581  TxID const& txID,
583  ApplyFlags const flags,
584  PreflightResult const& pfresult);
585 
588  apply(Application& app, OpenView& view, beast::Journal j);
589 
592  TxConsequences const&
593  consequences() const
594  {
595  return pfresult->consequences;
596  }
597 
599  TxDetails
600  getTxDetails() const
601  {
602  return {
603  feeLevel,
604  lastValid,
605  consequences(),
606  account,
607  seqProxy,
608  txn,
610  pfresult->ter,
611  lastResult};
612  }
613  };
614 
617  {
618  public:
620  explicit GreaterFee() = default;
621 
623  bool
624  operator()(const MaybeTx& lhs, const MaybeTx& rhs) const
625  {
626  return lhs.feeLevel > rhs.feeLevel;
627  }
628  };
629 
634  {
635  public:
637 
642  /* If this account has had any transaction retry more than
643  `retriesAllowed` times so that it was dropped from the
644  queue, then all other transactions for this account will
645  be given at most 2 attempts before being removed. Helps
646  prevent wasting resources on retries that are more likely
647  to fail.
648  */
649  bool retryPenalty = false;
650  /* If this account has had any transaction fail or expire,
651  then when the queue is nearly full, transactions from
652  this account will be discarded. Helps prevent the queue
653  from getting filled and wedged.
654  */
655  bool dropPenalty = false;
656 
657  public:
659  explicit TxQAccount(std::shared_ptr<STTx const> const& txn);
661  explicit TxQAccount(const AccountID& account);
662 
665  getTxnCount() const
666  {
667  return transactions.size();
668  }
669 
671  bool
672  empty() const
673  {
674  return !getTxnCount();
675  }
676 
678  TxMap::const_iterator
679  getPrevTx(SeqProxy seqProx) const;
680 
682  MaybeTx&
683  add(MaybeTx&&);
684 
690  bool
691  remove(SeqProxy seqProx);
692  };
693 
694  // Helper function returns requiredFeeLevel.
695  FeeLevel64
697  OpenView& view,
698  ApplyFlags flags,
699  FeeMetrics::Snapshot const& metricsSnapshot,
700  std::lock_guard<std::mutex> const& lock) const;
701 
702  // Helper function for TxQ::apply. If a transaction's fee is high enough,
703  // attempt to directly apply that transaction to the ledger.
706  Application& app,
707  OpenView& view,
708  std::shared_ptr<STTx const> const& tx,
709  ApplyFlags flags,
710  beast::Journal j);
711 
712  // Helper function that removes a replaced entry in _byFee.
713  boost::optional<TxQAccount::TxMap::iterator>
715  boost::optional<TxQAccount::TxMap::iterator> const& replacedTxIter,
716  std::shared_ptr<STTx const> const& tx);
717 
718  using FeeHook = boost::intrusive::member_hook<
719  MaybeTx,
720  boost::intrusive::set_member_hook<>,
722 
723  using FeeMultiSet = boost::intrusive::
724  multiset<MaybeTx, FeeHook, boost::intrusive::compare<GreaterFee>>;
725 
727 
729  Setup const setup_;
732 
757  boost::optional<size_t> maxSize_;
758 
763 
764 private:
766  template <size_t fillPercentage = 100>
767  bool
768  isFull() const;
769 
773  TER
774  canBeHeld(
775  STTx const&,
776  ApplyFlags const,
777  OpenView const&,
778  std::shared_ptr<SLE const> const& sleAccount,
779  AccountMap::iterator const&,
780  boost::optional<TxQAccount::TxMap::iterator> const&,
781  std::lock_guard<std::mutex> const& lock);
782 
784  FeeMultiSet::iterator_type erase(FeeMultiSet::const_iterator_type);
789  FeeMultiSet::iterator_type eraseAndAdvance(
790  FeeMultiSet::const_iterator_type);
792  TxQAccount::TxMap::iterator
793  erase(
794  TxQAccount& txQAccount,
795  TxQAccount::TxMap::const_iterator begin,
796  TxQAccount::TxMap::const_iterator end);
797 
805  Application& app,
806  OpenView& view,
807  STTx const& tx,
808  AccountMap::iterator const& accountIter,
809  TxQAccount::TxMap::iterator,
810  FeeLevel64 feeLevelPaid,
811  PreflightResult const& pfresult,
812  std::size_t const txExtraCount,
813  ApplyFlags flags,
814  FeeMetrics::Snapshot const& metricsSnapshot,
815  beast::Journal j);
816 };
817 
822 setup_TxQ(Config const&);
823 
824 template <class T>
825 XRPAmount
826 toDrops(FeeLevel<T> const& level, XRPAmount const& baseFee)
827 {
828  if (auto const drops = mulDiv(level, baseFee, TxQ::baseLevel); drops.first)
829  return drops.second;
830 
832 }
833 
834 inline FeeLevel64
835 toFeeLevel(XRPAmount const& drops, XRPAmount const& baseFee)
836 {
837  if (auto const feeLevel = mulDiv(drops, TxQ::baseLevel, baseFee);
838  feeLevel.first)
839  return feeLevel.second;
840 
842 }
843 
844 } // namespace ripple
845 
846 #endif
ripple::TxQ::TxDetails::lastResult
boost::optional< TER > lastResult
If the transactor attempted to apply the transaction to the open ledger from the queue and failed,...
Definition: TxQ.h:250
ripple::TxQ::setup_
const Setup setup_
Setup parameters used to control the behavior of the queue.
Definition: TxQ.h:729
ripple::setup_TxQ
TxQ::Setup setup_TxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
Definition: TxQ.cpp:1836
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:514
ripple::Application
Definition: Application.h:97
ripple::TxQ::FeeMetrics::maximumTxnCount_
const boost::optional< std::size_t > maximumTxnCount_
Maximum value of txnsExpected.
Definition: TxQ.h:381
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:176
std::shared_ptr
STL class.
ripple::TxQ::MaybeTx::lastResult
boost::optional< TER > lastResult
If the transactor attempted to apply the transaction to the open ledger from the queue and failed,...
Definition: TxQ.h:550
ripple::TxQ::getTxs
std::vector< TxDetails > getTxs(ReadView const &view) const
Returns information about all transactions currently in the queue.
Definition: TxQ.cpp:1777
ripple::TxQ::MaybeTx::txn
std::shared_ptr< STTx const > txn
The complete transaction.
Definition: TxQ.h:517
ripple::TxQ::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:731
ripple::TxQ::canBeHeld
TER canBeHeld(STTx const &, ApplyFlags const, OpenView const &, std::shared_ptr< SLE const > const &sleAccount, AccountMap::iterator const &, boost::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:368
ripple::TxQ::TxDetails::seqProxy
SeqProxy seqProxy
SeqProxy of the transaction.
Definition: TxQ.h:225
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:724
ripple::TxQ::FeeMetrics::FeeMetrics
FeeMetrics(Setup const &setup, beast::Journal j)
Constructor.
Definition: TxQ.h:397
ripple::OpenView
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:55
ripple::TxQ::MaybeTx::lastValid
const boost::optional< LedgerIndex > lastValid
Expiration ledger for the transaction (sfLastLedgerSequence field).
Definition: TxQ.h:527
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:633
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:451
ripple::CashFilter::none
@ none
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:372
ripple::ApplyFlags
ApplyFlags
Definition: ApplyView.h:30
ripple::TxQ::Metrics::txQMaxSize
boost::optional< std::size_t > txQMaxSize
Max transactions currently allowed in queue.
Definition: TxQ.h:167
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:450
ripple::TxQ::FeeMultiSet
boost::intrusive::multiset< MaybeTx, FeeHook, boost::intrusive::compare< GreaterFee > > FeeMultiSet
Definition: TxQ.h:724
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:189
ripple::TxQ::nextQueuableSeqImpl
SeqProxy nextQueuableSeqImpl(std::shared_ptr< SLE const > const &sleAccount, std::lock_guard< std::mutex > const &) const
Definition: TxQ.cpp:1559
ripple::TxQ::TxQAccount::remove
bool remove(SeqProxy seqProx)
Remove the candidate with given SeqProxy value from this account.
Definition: TxQ.cpp:341
ripple::TxQ::MaybeTx::flags
const ApplyFlags flags
Flags provided to apply.
Definition: TxQ.h:543
ripple::TxQ::FeeMetrics::escalationMultiplier_
FeeLevel64 escalationMultiplier_
Based on the median fee of the LCL.
Definition: TxQ.h:391
ripple::TxQ::isFull
bool isFull() const
Is the queue at least fillPercentage full?
Definition: TxQ.cpp:360
ripple::TxQ::FeeAndSeq
Definition: TxQ.h:314
boost
Definition: IPAddress.h:117
ripple::TxQ::TxDetails::lastValid
boost::optional< LedgerIndex > lastValid
LastValidLedger field of the queued transaction, if any.
Definition: TxQ.h:217
ripple::toFeeLevel
FeeLevel64 toFeeLevel(XRPAmount const &drops, XRPAmount const &baseFee)
Definition: TxQ.h:835
ripple::TxQ::FeeMetrics::recentTxnCounts_
boost::circular_buffer< std::size_t > recentTxnCounts_
Recent history of transaction counts that exceed the targetTxnCount_.
Definition: TxQ.h:388
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:641
ripple::TxQ::Metrics
Structure returned by TxQ::getMetrics, expressed in reference fee level units.
Definition: TxQ.h:159
ripple::TxQ::accept
bool accept(Application &app, OpenView &view)
Fill the new open ledger with transactions from the queue.
Definition: TxQ.cpp:1406
ripple::TxQ::Setup::maximumTxnPerAccount
std::uint32_t maximumTxnPerAccount
Maximum number of transactions that can be queued by one account.
Definition: TxQ.h:143
ripple::TxQ::TxDetails::TxDetails
TxDetails(FeeLevel64 feeLevel_, boost::optional< LedgerIndex > const &lastValid_, TxConsequences const &consequences_, AccountID const &account_, SeqProxy seqProxy_, std::shared_ptr< STTx const > const &txn_, int retriesRemaining_, TER preflightResult_, boost::optional< TER > lastResult_)
Full initialization.
Definition: TxQ.h:192
ripple::TxQ::FeeHook
boost::intrusive::member_hook< MaybeTx, boost::intrusive::set_member_hook<>, &MaybeTx::byFeeListHook > FeeHook
Definition: TxQ.h:721
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:600
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:127
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:514
ripple::TxQ::Setup::maximumTxnInLedger
boost::optional< std::uint32_t > maximumTxnInLedger
Optional maximum allowed value of transactions per ledger before fee escalation kicks in.
Definition: TxQ.h:115
ripple::TxQ::TxQAccount::retryPenalty
bool retryPenalty
Definition: TxQ.h:649
ripple::TxQ::MaybeTx::feeLevel
const FeeLevel64 feeLevel
Computed fee level that the transaction will pay.
Definition: TxQ.h:520
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:104
ripple::toDrops
XRPAmount toDrops(FeeLevel< T > const &level, XRPAmount const &baseFee)
Definition: TxQ.h:826
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:152
ripple::TxQ
Transaction Queue.
Definition: TxQ.h:55
ripple::TxQ::byFee_
FeeMultiSet byFee_
The queue itself: the collection of transactions ordered by fee level.
Definition: TxQ.h:743
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:616
ripple::Config
Definition: Config.h:69
ripple::TxQ::TxDetails::account
AccountID account
The account the transaction is queued for.
Definition: TxQ.h:223
ripple::TxQ::feeMetrics_
FeeMetrics feeMetrics_
Tracks the current state of the queue.
Definition: TxQ.h:737
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:98
ripple::TxQ::Setup
Structure used to customize TxQ behavior.
Definition: TxQ.h:64
ripple::TxQ::TxQAccount::account
const AccountID account
The account.
Definition: TxQ.h:639
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:318
ripple::TERSubset< CanCvtToTER >
ripple::TxQ::removeFromByFee
boost::optional< TxQAccount::TxMap::iterator > removeFromByFee(boost::optional< TxQAccount::TxMap::iterator > const &replacedTxIter, std::shared_ptr< STTx const > const &tx)
Definition: TxQ.cpp:1693
ripple::TxQ::TxQAccount::add
MaybeTx & add(MaybeTx &&)
Add a transaction candidate to this account for queuing.
Definition: TxQ.cpp:329
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:624
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:1735
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:1546
ripple::TxQ::MaybeTx
Represents a transaction in the queue which may be applied later to the open ledger.
Definition: TxQ.h:508
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:233
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:141
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:59
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:376
ripple::TxQ::FeeAndSeq::accountSeq
std::uint32_t accountSeq
Definition: TxQ.h:317
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:1337
ripple::TxQ::MaybeTx::seqProxy
const SeqProxy seqProxy
Transaction SeqProxy number (sfSequence or sfTicketSequence field).
Definition: TxQ.h:530
ripple::TxQ::doRPC
Json::Value doRPC(Application &app) const
Summarize current fee metrics for the fee RPC command.
Definition: TxQ.cpp:1792
ripple::TxQ::FeeMetrics::targetTxnCount_
const std::size_t targetTxnCount_
Number of transactions per ledger that fee escalation "works towards".
Definition: TxQ.h:379
ripple::TxQ::MaybeTx::pfresult
boost::optional< PreflightResult const > pfresult
Cached result of the preflight operation.
Definition: TxQ.h:559
ripple::TxQ::MaybeTx::consequences
TxConsequences const & consequences() const
Potential TxConsequences of applying this transaction to the open ledger.
Definition: TxQ.h:593
ripple::TxQ::TxQAccount::dropPenalty
bool dropPenalty
Definition: TxQ.h:655
ripple::TxQ::Metrics::referenceFeeLevel
FeeLevel64 referenceFeeLevel
Reference transaction fee level.
Definition: TxQ.h:173
ripple::TxQ::TxDetails::consequences
TxConsequences consequences
Potential TxConsequences of applying the queued transaction to the open ledger.
Definition: TxQ.h:221
ripple::TxQ::~TxQ
virtual ~TxQ()
Destructor.
Definition: TxQ.cpp:353
ripple::TxQ::TxQAccount::empty
bool empty() const
Checks if this account has no transactions queued.
Definition: TxQ.h:672
ripple::TxQ::Metrics::medFeeLevel
FeeLevel64 medFeeLevel
Median fee level of the last ledger.
Definition: TxQ.h:178
ripple::TxQ::FeeMetrics::Snapshot
Snapshot of the externally relevant FeeMetrics fields at any given time.
Definition: TxQ.h:437
ripple::TxQ::FeeMetrics::Snapshot::escalationMultiplier
const FeeLevel64 escalationMultiplier
Definition: TxQ.h:445
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:348
ripple::TxQ::TxQAccount::getTxnCount
std::size_t getTxnCount() const
Return the number of transactions currently queued for this account.
Definition: TxQ.h:665
ripple::TxQ::maxSize_
boost::optional< size_t > maxSize_
Maximum number of transactions allowed in the queue based on the current metrics.
Definition: TxQ.h:757
ripple::TxQ::getRequiredFeeLevel
FeeLevel64 getRequiredFeeLevel(OpenView &view, ApplyFlags flags, FeeMetrics::Snapshot const &metricsSnapshot, std::lock_guard< std::mutex > const &lock) const
Definition: TxQ.cpp:1606
ripple::TxQ::MaybeTx::account
const AccountID account
Account submitting the transaction.
Definition: TxQ.h:524
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:169
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:762
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:575
ripple::TxQ::FeeMetrics::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:393
ripple::TxQ::Metrics::txCount
std::size_t txCount
Number of transactions in the queue.
Definition: TxQ.h:165
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:92
std::optional
std::mutex
STL class.
ripple::TxQ::Setup::minimumTxnInLedgerSA
std::uint32_t minimumTxnInLedgerSA
Like minimumTxnInLedger for standalone mode.
Definition: TxQ.h:101
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:243
ripple::TxQ::TxQAccount::TxQAccount
TxQAccount(std::shared_ptr< STTx const > const &txn)
Construct from a transaction.
Definition: TxQ.cpp:308
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:1622
ripple::TxQ::TxDetails::feeLevel
FeeLevel64 feeLevel
Fee level of the queued transaction.
Definition: TxQ.h:215
ripple::STAmount::cMaxNativeN
static const std::uint64_t cMaxNativeN
Definition: STAmount.h:68
ripple::TxQ::Metrics::openLedgerFeeLevel
FeeLevel64 openLedgerFeeLevel
Minimum fee level to get into the current open ledger, bypassing the queue.
Definition: TxQ.h:181
ripple::TxQ::Setup::queueSizeMin
std::size_t queueSizeMin
The smallest limit the queue is allowed.
Definition: TxQ.h:82
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:1756
ripple::TxQ::byAccount_
AccountMap byAccount_
All of the accounts which currently have any transactions in the queue.
Definition: TxQ.h:750
ripple::TxQ::getMetrics
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
Definition: TxQ.cpp:1713
ripple::TxQ::FeeMetrics::txnsExpected_
std::size_t txnsExpected_
Number of transactions expected per ledger.
Definition: TxQ.h:385
ripple::TxQ::Setup::minimumEscalationMultiplier
FeeLevel64 minimumEscalationMultiplier
Minimum value of the escalation multiplier, regardless of the prior ledger's median fee level.
Definition: TxQ.h:95
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:539
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:150
ripple::TxQ::MaybeTx::txID
const TxID txID
Transaction ID.
Definition: TxQ.h:522
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:76
ripple::TxQ::FeeAndSeq::availableSeq
std::uint32_t availableSeq
Definition: TxQ.h:318
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:442
ripple::TxQ::TxDetails::txn
std::shared_ptr< STTx const > txn
The full transaction.
Definition: TxQ.h:227
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:316
ripple::TxQ::Metrics::txPerLedger
std::size_t txPerLedger
Number of transactions expected per ledger.
Definition: TxQ.h:171