rippled
Loading...
Searching...
No Matches
RippleCalc.h
1#ifndef XRPL_APP_PATHS_RIPPLECALC_H_INCLUDED
2#define XRPL_APP_PATHS_RIPPLECALC_H_INCLUDED
3
4#include <xrpl/basics/Log.h>
5#include <xrpl/ledger/PaymentSandbox.h>
6#include <xrpl/protocol/STAmount.h>
7#include <xrpl/protocol/TER.h>
8
9#include <boost/container/flat_set.hpp>
10
11namespace ripple {
12class Config;
13namespace path {
14
15namespace detail {
16struct FlowDebugInfo;
17}
18
25{
26public:
27 struct Input
28 {
29 explicit Input() = default;
30
33 bool limitQuality = false;
34 bool isLedgerOpen = true;
35 };
36 struct Output
37 {
38 explicit Output() = default;
39
40 // The computed input amount.
42
43 // The computed output amount.
45
46 // Collection of offers found expired or unfunded. When a payment
47 // succeeds, unfunded and expired offers are removed. When a payment
48 // fails, they are not removed. This vector contains the offers that
49 // could have been removed but were not because the payment fails. It is
50 // useful for offer crossing, which does remove the offers.
51 boost::container::flat_set<uint256> removableOffers;
52
53 private:
55
56 public:
57 TER
58 result() const
59 {
60 return calculationResult_;
61 }
62 void
63 setResult(TER const value)
64 {
65 calculationResult_ = value;
66 }
67 };
68
69 static Output
72
73 // Compute paths using this ledger entry set. Up to caller to actually
74 // apply to ledger.
75
76 // Issuer:
77 // XRP: xrpAccount()
78 // non-XRP: uSrcAccountID (for any issuer) or another account with
79 // trust node.
80 STAmount const& saMaxAmountReq, // --> -1 = no limit.
81
82 // Issuer:
83 // XRP: xrpAccount()
84 // non-XRP: uDstAccountID (for any issuer) or another account with
85 // trust node.
86 STAmount const& saDstAmountReq,
87
88 AccountID const& uDstAccountID,
89 AccountID const& uSrcAccountID,
90
91 // A set of paths that are included in the transaction that we'll
92 // explore for liquidity.
93 STPathSet const& spsPaths,
94
95 std::optional<uint256> const& domainID,
96 Logs& l,
97 Input const* const pInputs = nullptr);
98
99 // The view we are currently working on
101
102 // If the transaction fails to meet some constraint, still need to delete
103 // unfunded offers in a deterministic order (hence the ordered container).
104 //
105 // Offers that were found unfunded.
106 boost::container::flat_set<uint256> permanentlyUnfundedOffers_;
107};
108
109} // namespace path
110} // namespace ripple
111
112#endif
Manages partitions for logging.
Definition Log.h:33
A wrapper which makes credits unavailable to balances.
RippleCalc calculates the quality of a payment path.
Definition RippleCalc.h:25
PaymentSandbox & view
Definition RippleCalc.h:100
boost::container::flat_set< uint256 > permanentlyUnfundedOffers_
Definition RippleCalc.h:106
static Output rippleCalculate(PaymentSandbox &view, STAmount const &saMaxAmountReq, STAmount const &saDstAmountReq, AccountID const &uDstAccountID, AccountID const &uSrcAccountID, STPathSet const &spsPaths, std::optional< uint256 > const &domainID, Logs &l, Input const *const pInputs=nullptr)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
@ temUNKNOWN
Definition TER.h:105
boost::container::flat_set< uint256 > removableOffers
Definition RippleCalc.h:51
void setResult(TER const value)
Definition RippleCalc.h:63