rippled
Loading...
Searching...
No Matches
TrustLine.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_RIPPLESTATE_H_INCLUDED
21#define RIPPLE_APP_PATHS_RIPPLESTATE_H_INCLUDED
22
23#include <xrpl/basics/CountedObject.h>
24#include <xrpl/ledger/View.h>
25#include <xrpl/protocol/Rate.h>
26#include <xrpl/protocol/STAmount.h>
27#include <xrpl/protocol/STLedgerEntry.h>
28
29#include <cstdint>
30#include <optional>
31
32namespace ripple {
33
41enum class LineDirection : bool { incoming = false, outgoing = true };
42
54{
55protected:
56 // This class should not be instantiated directly. Use one of the derived
57 // classes.
60 AccountID const& viewAccount);
61
62 ~TrustLineBase() = default;
63 TrustLineBase(TrustLineBase const&) = default;
65 operator=(TrustLineBase const&) = delete;
67
68public:
70 uint256 const&
71 key() const
72 {
73 return key_;
74 }
75
76 // VFALCO Take off the "get" from each function name
77
78 AccountID const&
80 {
82 }
83
84 AccountID const&
86 {
88 }
89
90 // True, Provided auth to peer.
91 bool
92 getAuth() const
93 {
95 }
96
97 bool
99 {
101 }
102
103 bool
105 {
107 }
108
109 bool
111 {
113 }
114
121
128
130 bool
131 getFreeze() const
132 {
134 }
135
137 bool
139 {
141 }
142
144 bool
146 {
148 }
149
151 bool
156
157 STAmount const&
159 {
160 return mBalance;
161 }
162
163 STAmount const&
164 getLimit() const
165 {
167 }
168
169 STAmount const&
171 {
172 return !mViewLowest ? mLowLimit : mHighLimit;
173 }
174
176 getJson(int);
177
178protected:
180
183
185
187
189};
190
191// This wrapper is used for the path finder
192class PathFindTrustLine final : public TrustLineBase,
193 public CountedObject<PathFindTrustLine>
194{
196
197public:
199
201 makeItem(AccountID const& accountID, std::shared_ptr<SLE const> const& sle);
202
204 getItems(
205 AccountID const& accountID,
206 ReadView const& view,
207 LineDirection direction);
208};
209
210// This wrapper is used for the `AccountLines` command and includes the quality
211// in and quality out values.
212class RPCTrustLine final : public TrustLineBase,
213 public CountedObject<RPCTrustLine>
214{
216
217public:
218 RPCTrustLine() = delete;
219
222 AccountID const& viewAccount);
223
224 Rate const&
226 {
228 }
229
230 Rate const&
232 {
234 }
235
237 makeItem(AccountID const& accountID, std::shared_ptr<SLE const> const& sle);
238
240 getItems(AccountID const& accountID, ReadView const& view);
241
242private:
247};
248
249} // namespace ripple
250
251#endif
Represents a JSON value.
Definition json_value.h:149
Tracks the number of instances of an object.
static std::vector< PathFindTrustLine > getItems(AccountID const &accountID, ReadView const &view, LineDirection direction)
Definition TrustLine.cpp:89
static std::optional< PathFindTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
Definition TrustLine.cpp:52
Rate const & getQualityIn() const
Definition TrustLine.h:225
static std::optional< RPCTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
static std::vector< RPCTrustLine > getItems(AccountID const &accountID, ReadView const &view)
Rate const & getQualityOut() const
Definition TrustLine.h:231
A view into a ledger.
Definition ReadView.h:51
AccountID const & getIssuer() const
Definition STAmount.h:508
Wraps a trust line SLE for convenience.
Definition TrustLine.h:54
bool getDeepFreeze() const
Have we set the deep freeze flag on our peer.
Definition TrustLine.h:138
std::uint32_t mFlags
Definition TrustLine.h:186
STAmount const & getLimit() const
Definition TrustLine.h:164
STAmount const mLowLimit
Definition TrustLine.h:181
STAmount const & getBalance() const
Definition TrustLine.h:158
bool getAuthPeer() const
Definition TrustLine.h:98
TrustLineBase(std::shared_ptr< SLE const > const &sle, AccountID const &viewAccount)
Definition TrustLine.cpp:28
TrustLineBase(TrustLineBase &&)=default
AccountID const & getAccountID() const
Definition TrustLine.h:79
uint256 const & key() const
Returns the state map key for the ledger entry.
Definition TrustLine.h:71
STAmount const & getLimitPeer() const
Definition TrustLine.h:170
STAmount const mHighLimit
Definition TrustLine.h:182
bool getNoRipplePeer() const
Definition TrustLine.h:110
bool getNoRipple() const
Definition TrustLine.h:104
Json::Value getJson(int)
Definition TrustLine.cpp:43
bool getFreezePeer() const
Has the peer set the freeze flag on us.
Definition TrustLine.h:145
AccountID const & getAccountIDPeer() const
Definition TrustLine.h:85
bool getFreeze() const
Have we set the freeze flag on our peer.
Definition TrustLine.h:131
TrustLineBase(TrustLineBase const &)=default
LineDirection getDirectionPeer() const
Definition TrustLine.h:123
bool getAuth() const
Definition TrustLine.h:92
LineDirection getDirection() const
Definition TrustLine.h:116
bool getDeepFreezePeer() const
Has the peer set the deep freeze flag on us.
Definition TrustLine.h:152
TrustLineBase & operator=(TrustLineBase const &)=delete
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
@ 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:41
Represents a transfer rate.
Definition Rate.h:40