rippled
RippleState.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 <ripple/ledger/View.h>
24 #include <ripple/protocol/Rate.h>
25 #include <ripple/protocol/STAmount.h>
26 #include <ripple/protocol/STLedgerEntry.h>
27 #include <cstdint>
28 #include <memory> // <memory>
29 
30 namespace ripple {
31 
38 // VFALCO TODO Rename to TrustLine
40 {
41 public:
42  // VFALCO Why is this shared_ptr?
44 
45 public:
46  RippleState() = delete;
47 
48  virtual ~RippleState() = default;
49 
51  makeItem(AccountID const& accountID, std::shared_ptr<SLE const> sle);
52 
53  // Must be public, for make_shared
54  RippleState(std::shared_ptr<SLE const>&& sle, AccountID const& viewAccount);
55 
57  uint256
58  key() const
59  {
60  return sle_->key();
61  }
62 
63  // VFALCO Take off the "get" from each function name
64 
65  AccountID const&
66  getAccountID() const
67  {
68  return mViewLowest ? mLowID : mHighID;
69  }
70 
71  AccountID const&
73  {
74  return !mViewLowest ? mLowID : mHighID;
75  }
76 
77  // True, Provided auth to peer.
78  bool
79  getAuth() const
80  {
82  }
83 
84  bool
85  getAuthPeer() const
86  {
87  return mFlags & (!mViewLowest ? lsfLowAuth : lsfHighAuth);
88  }
89 
90  bool
92  {
93  return mFlags & lsfDefaultRipple;
94  }
95 
96  bool
97  getNoRipple() const
98  {
100  }
101 
102  bool
104  {
106  }
107 
109  bool
110  getFreeze() const
111  {
113  }
114 
116  bool
118  {
120  }
121 
122  STAmount const&
123  getBalance() const
124  {
125  return mBalance;
126  }
127 
128  STAmount const&
129  getLimit() const
130  {
131  return mViewLowest ? mLowLimit : mHighLimit;
132  }
133 
134  STAmount const&
135  getLimitPeer() const
136  {
137  return !mViewLowest ? mLowLimit : mHighLimit;
138  }
139 
140  Rate const&
141  getQualityIn() const
142  {
144  }
145 
146  Rate const&
148  {
150  }
151 
153  getJson(int);
154 
155 private:
157 
159 
161 
164 
167 
172 
174 };
175 
177 getRippleStateItems(AccountID const& accountID, ReadView const& view);
178 
179 } // namespace ripple
180 
181 #endif
ripple::RippleState::lowQualityOut_
Rate lowQualityOut_
Definition: RippleState.h:169
ripple::RippleState
Wraps a trust line SLE for convenience.
Definition: RippleState.h:39
ripple::RippleState::getAuthPeer
bool getAuthPeer() const
Definition: RippleState.h:85
ripple::RippleState::getQualityIn
Rate const & getQualityIn() const
Definition: RippleState.h:141
std::shared_ptr
STL class.
ripple::Rate
Represents a transfer rate.
Definition: Rate.h:37
ripple::RippleState::getAccountID
AccountID const & getAccountID() const
Definition: RippleState.h:66
ripple::RippleState::getFreezePeer
bool getFreezePeer() const
Has the peer set the freeze flag on us.
Definition: RippleState.h:117
ripple::RippleState::getDefaultRipple
bool getDefaultRipple() const
Definition: RippleState.h:91
ripple::lsfLowAuth
@ lsfLowAuth
Definition: LedgerFormats.h:123
ripple::lsfLowNoRipple
@ lsfLowNoRipple
Definition: LedgerFormats.h:125
ripple::RippleState::highQualityOut_
Rate highQualityOut_
Definition: RippleState.h:171
std::vector
STL class.
ripple::RippleState::mLowID
AccountID const & mLowID
Definition: RippleState.h:165
ripple::RippleState::getAuth
bool getAuth() const
Definition: RippleState.h:79
ripple::lsfHighAuth
@ lsfHighAuth
Definition: LedgerFormats.h:124
ripple::RippleState::highQualityIn_
Rate highQualityIn_
Definition: RippleState.h:170
ripple::getRippleStateItems
std::vector< RippleState::pointer > getRippleStateItems(AccountID const &accountID, ReadView const &view)
Definition: RippleState.cpp:70
ripple::base_uint< 160, detail::AccountIDTag >
ripple::RippleState::getLimit
STAmount const & getLimit() const
Definition: RippleState.h:129
ripple::RippleState::getAccountIDPeer
AccountID const & getAccountIDPeer() const
Definition: RippleState.h:72
ripple::RippleState::~RippleState
virtual ~RippleState()=default
ripple::lsfDefaultRipple
@ lsfDefaultRipple
Definition: LedgerFormats.h:112
ripple::RippleState::sle_
std::shared_ptr< SLE const > sle_
Definition: RippleState.h:156
ripple::RippleState::makeItem
static RippleState::pointer makeItem(AccountID const &accountID, std::shared_ptr< SLE const > sle)
Definition: RippleState.cpp:29
ripple::RippleState::getQualityOut
Rate const & getQualityOut() const
Definition: RippleState.h:147
ripple::RippleState::getNoRipple
bool getNoRipple() const
Definition: RippleState.h:97
ripple::RippleState::getFreeze
bool getFreeze() const
Have we set the freeze flag on our peer.
Definition: RippleState.h:110
ripple::STAmount
Definition: STAmount.h:42
ripple::RippleState::getNoRipplePeer
bool getNoRipplePeer() const
Definition: RippleState.h:103
ripple::RippleState::mHighLimit
STAmount const & mHighLimit
Definition: RippleState.h:163
ripple::RippleState::getJson
Json::Value getJson(int)
Definition: RippleState.cpp:61
cstdint
std::uint32_t
ripple::RippleState::key
uint256 key() const
Returns the state map key for the ledger entry.
Definition: RippleState.h:58
memory
ripple::lsfHighNoRipple
@ lsfHighNoRipple
Definition: LedgerFormats.h:126
ripple::lsfHighFreeze
@ lsfHighFreeze
Definition: LedgerFormats.h:128
ripple::RippleState::mLowLimit
STAmount const & mLowLimit
Definition: RippleState.h:162
ripple::RippleState::lowQualityIn_
Rate lowQualityIn_
Definition: RippleState.h:168
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:192
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::RippleState::getBalance
STAmount const & getBalance() const
Definition: RippleState.h:123
ripple::RippleState::RippleState
RippleState()=delete
ripple::RippleState::mBalance
STAmount mBalance
Definition: RippleState.h:173
ripple::lsfLowFreeze
@ lsfLowFreeze
Definition: LedgerFormats.h:127
ripple::RippleState::mViewLowest
bool mViewLowest
Definition: RippleState.h:158
ripple::RippleState::mHighID
AccountID const & mHighID
Definition: RippleState.h:166
ripple::RippleState::getLimitPeer
STAmount const & getLimitPeer() const
Definition: RippleState.h:135
ripple::RippleState::mFlags
std::uint32_t mFlags
Definition: RippleState.h:160
Json::Value
Represents a JSON value.
Definition: json_value.h:145