rippled
Loading...
Searching...
No Matches
TrustLine.h
1#ifndef XRPL_APP_PATHS_RIPPLESTATE_H_INCLUDED
2#define XRPL_APP_PATHS_RIPPLESTATE_H_INCLUDED
3
4#include <xrpl/basics/CountedObject.h>
5#include <xrpl/ledger/View.h>
6#include <xrpl/protocol/Rate.h>
7#include <xrpl/protocol/STAmount.h>
8#include <xrpl/protocol/STLedgerEntry.h>
9
10#include <cstdint>
11#include <optional>
12
13namespace ripple {
14
22enum class LineDirection : bool { incoming = false, outgoing = true };
23
35{
36protected:
37 // This class should not be instantiated directly. Use one of the derived
38 // classes.
41 AccountID const& viewAccount);
42
43 ~TrustLineBase() = default;
44 TrustLineBase(TrustLineBase const&) = default;
46 operator=(TrustLineBase const&) = delete;
48
49public:
51 uint256 const&
52 key() const
53 {
54 return key_;
55 }
56
57 // VFALCO Take off the "get" from each function name
58
59 AccountID const&
61 {
63 }
64
65 AccountID const&
67 {
69 }
70
71 // True, Provided auth to peer.
72 bool
73 getAuth() const
74 {
76 }
77
78 bool
80 {
82 }
83
84 bool
86 {
88 }
89
90 bool
92 {
94 }
95
102
109
111 bool
112 getFreeze() const
113 {
115 }
116
118 bool
120 {
122 }
123
125 bool
127 {
129 }
130
132 bool
137
138 STAmount const&
140 {
141 return mBalance;
142 }
143
144 STAmount const&
145 getLimit() const
146 {
148 }
149
150 STAmount const&
152 {
153 return !mViewLowest ? mLowLimit : mHighLimit;
154 }
155
157 getJson(int);
158
159protected:
161
164
166
168
170};
171
172// This wrapper is used for the path finder
173class PathFindTrustLine final : public TrustLineBase,
174 public CountedObject<PathFindTrustLine>
175{
177
178public:
180
182 makeItem(AccountID const& accountID, std::shared_ptr<SLE const> const& sle);
183
185 getItems(
186 AccountID const& accountID,
187 ReadView const& view,
188 LineDirection direction);
189};
190
191// This wrapper is used for the `AccountLines` command and includes the quality
192// in and quality out values.
193class RPCTrustLine final : public TrustLineBase,
194 public CountedObject<RPCTrustLine>
195{
197
198public:
199 RPCTrustLine() = delete;
200
203 AccountID const& viewAccount);
204
205 Rate const&
207 {
209 }
210
211 Rate const&
213 {
215 }
216
218 makeItem(AccountID const& accountID, std::shared_ptr<SLE const> const& sle);
219
221 getItems(AccountID const& accountID, ReadView const& view);
222
223private:
228};
229
230} // namespace ripple
231
232#endif
Represents a JSON value.
Definition json_value.h:131
Tracks the number of instances of an object.
static std::vector< PathFindTrustLine > getItems(AccountID const &accountID, ReadView const &view, LineDirection direction)
Definition TrustLine.cpp:70
static std::optional< PathFindTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
Definition TrustLine.cpp:33
Rate const & getQualityIn() const
Definition TrustLine.h:206
static std::optional< RPCTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
Definition TrustLine.cpp:91
static std::vector< RPCTrustLine > getItems(AccountID const &accountID, ReadView const &view)
Rate const & getQualityOut() const
Definition TrustLine.h:212
A view into a ledger.
Definition ReadView.h:32
AccountID const & getIssuer() const
Definition STAmount.h:489
Wraps a trust line SLE for convenience.
Definition TrustLine.h:35
bool getDeepFreeze() const
Have we set the deep freeze flag on our peer.
Definition TrustLine.h:119
std::uint32_t mFlags
Definition TrustLine.h:167
STAmount const & getLimit() const
Definition TrustLine.h:145
STAmount const mLowLimit
Definition TrustLine.h:162
STAmount const & getBalance() const
Definition TrustLine.h:139
bool getAuthPeer() const
Definition TrustLine.h:79
TrustLineBase(std::shared_ptr< SLE const > const &sle, AccountID const &viewAccount)
Definition TrustLine.cpp:9
TrustLineBase(TrustLineBase &&)=default
AccountID const & getAccountID() const
Definition TrustLine.h:60
uint256 const & key() const
Returns the state map key for the ledger entry.
Definition TrustLine.h:52
STAmount const & getLimitPeer() const
Definition TrustLine.h:151
STAmount const mHighLimit
Definition TrustLine.h:163
bool getNoRipplePeer() const
Definition TrustLine.h:91
bool getNoRipple() const
Definition TrustLine.h:85
Json::Value getJson(int)
Definition TrustLine.cpp:24
bool getFreezePeer() const
Has the peer set the freeze flag on us.
Definition TrustLine.h:126
AccountID const & getAccountIDPeer() const
Definition TrustLine.h:66
bool getFreeze() const
Have we set the freeze flag on our peer.
Definition TrustLine.h:112
TrustLineBase(TrustLineBase const &)=default
LineDirection getDirectionPeer() const
Definition TrustLine.h:104
bool getAuth() const
Definition TrustLine.h:73
LineDirection getDirection() const
Definition TrustLine.h:97
bool getDeepFreezePeer() const
Has the peer set the deep freeze flag on us.
Definition TrustLine.h:133
TrustLineBase & operator=(TrustLineBase const &)=delete
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
@ lsfHighDeepFreeze
@ lsfHighNoRipple
@ lsfLowDeepFreeze
LineDirection
Describes how an account was found in a path, and how to find the next set of paths.
Definition TrustLine.h:22
Represents a transfer rate.
Definition Rate.h:21