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