rippled
Loading...
Searching...
No Matches
RippleCalc.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 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_APP_PATHS_RIPPLECALC_H_INCLUDED
21#define RIPPLE_APP_PATHS_RIPPLECALC_H_INCLUDED
22
23#include <xrpl/basics/Log.h>
24#include <xrpl/ledger/PaymentSandbox.h>
25#include <xrpl/protocol/STAmount.h>
26#include <xrpl/protocol/TER.h>
27
28#include <boost/container/flat_set.hpp>
29
30namespace ripple {
31class Config;
32namespace path {
33
34namespace detail {
35struct FlowDebugInfo;
36}
37
44{
45public:
46 struct Input
47 {
48 explicit Input() = default;
49
52 bool limitQuality = false;
53 bool isLedgerOpen = true;
54 };
55 struct Output
56 {
57 explicit Output() = default;
58
59 // The computed input amount.
61
62 // The computed output amount.
64
65 // Collection of offers found expired or unfunded. When a payment
66 // succeeds, unfunded and expired offers are removed. When a payment
67 // fails, they are not removed. This vector contains the offers that
68 // could have been removed but were not because the payment fails. It is
69 // useful for offer crossing, which does remove the offers.
70 boost::container::flat_set<uint256> removableOffers;
71
72 private:
74
75 public:
76 TER
77 result() const
78 {
79 return calculationResult_;
80 }
81 void
82 setResult(TER const value)
83 {
84 calculationResult_ = value;
85 }
86 };
87
88 static Output
91
92 // Compute paths using this ledger entry set. Up to caller to actually
93 // apply to ledger.
94
95 // Issuer:
96 // XRP: xrpAccount()
97 // non-XRP: uSrcAccountID (for any issuer) or another account with
98 // trust node.
99 STAmount const& saMaxAmountReq, // --> -1 = no limit.
100
101 // Issuer:
102 // XRP: xrpAccount()
103 // non-XRP: uDstAccountID (for any issuer) or another account with
104 // trust node.
105 STAmount const& saDstAmountReq,
106
107 AccountID const& uDstAccountID,
108 AccountID const& uSrcAccountID,
109
110 // A set of paths that are included in the transaction that we'll
111 // explore for liquidity.
112 STPathSet const& spsPaths,
113
114 std::optional<uint256> const& domainID,
115 Logs& l,
116 Input const* const pInputs = nullptr);
117
118 // The view we are currently working on
120
121 // If the transaction fails to meet some constraint, still need to delete
122 // unfunded offers in a deterministic order (hence the ordered container).
123 //
124 // Offers that were found unfunded.
125 boost::container::flat_set<uint256> permanentlyUnfundedOffers_;
126};
127
128} // namespace path
129} // namespace ripple
130
131#endif
Manages partitions for logging.
Definition Log.h:52
A wrapper which makes credits unavailable to balances.
RippleCalc calculates the quality of a payment path.
Definition RippleCalc.h:44
PaymentSandbox & view
Definition RippleCalc.h:119
boost::container::flat_set< uint256 > permanentlyUnfundedOffers_
Definition RippleCalc.h:125
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:25
@ temUNKNOWN
Definition TER.h:124
boost::container::flat_set< uint256 > removableOffers
Definition RippleCalc.h:70
void setResult(TER const value)
Definition RippleCalc.h:82