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 <xrpld/ledger/PaymentSandbox.h>
24#include <xrpl/basics/Log.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 Logs& l,
114 Input const* const pInputs = nullptr);
115
116 // The view we are currently working on
118
119 // If the transaction fails to meet some constraint, still need to delete
120 // unfunded offers in a deterministic order (hence the ordered container).
121 //
122 // Offers that were found unfunded.
123 boost::container::flat_set<uint256> permanentlyUnfundedOffers_;
124};
125
126} // namespace path
127} // namespace ripple
128
129#endif
Manages partitions for logging.
Definition: Log.h:49
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:117
static Output rippleCalculate(PaymentSandbox &view, STAmount const &saMaxAmountReq, STAmount const &saDstAmountReq, AccountID const &uDstAccountID, AccountID const &uSrcAccountID, STPathSet const &spsPaths, Logs &l, Input const *const pInputs=nullptr)
Definition: RippleCalc.cpp:31
boost::container::flat_set< uint256 > permanentlyUnfundedOffers_
Definition: RippleCalc.h:123
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
@ temUNKNOWN
Definition: TER.h:124
boost::container::flat_set< uint256 > removableOffers
Definition: RippleCalc.h:70
void setResult(TER const value)
Definition: RippleCalc.h:82