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  AccountID const& accountID,
53 
54  // Must be public, for make_shared
56  AccountID const& viewAccount);
57 
59  uint256
60  key() const
61  {
62  return sle_->key();
63  }
64 
65  // VFALCO Take off the "get" from each function name
66 
67  AccountID const& getAccountID () const
68  {
69  return mViewLowest ? mLowID : mHighID;
70  }
71 
72  AccountID const& getAccountIDPeer () const
73  {
74  return !mViewLowest ? mLowID : mHighID;
75  }
76 
77  // True, Provided auth to peer.
78  bool getAuth () const
79  {
81  }
82 
83  bool getAuthPeer () const
84  {
85  return mFlags & (!mViewLowest ? lsfLowAuth : lsfHighAuth);
86  }
87 
88  bool getNoRipple () const
89  {
91  }
92 
93  bool getNoRipplePeer () const
94  {
96  }
97 
99  bool getFreeze () const
100  {
102  }
103 
105  bool getFreezePeer () const
106  {
108  }
109 
110  STAmount const& getBalance () const
111  {
112  return mBalance;
113  }
114 
115  STAmount const& getLimit () const
116  {
117  return mViewLowest ? mLowLimit : mHighLimit;
118  }
119 
120  STAmount const& getLimitPeer () const
121  {
122  return !mViewLowest ? mLowLimit : mHighLimit;
123  }
124 
125  Rate const&
126  getQualityIn () const
127  {
129  }
130 
131  Rate const&
132  getQualityOut () const
133  {
135  }
136 
137  Json::Value getJson (int);
138 
139 private:
141 
143 
145 
148 
151 
156 
158 };
159 
161 getRippleStateItems (AccountID const& accountID,
162  ReadView const& view);
163 
164 } // ripple
165 
166 #endif
ripple::RippleState::lowQualityOut_
Rate lowQualityOut_
Definition: RippleState.h:153
ripple::RippleState
Wraps a trust line SLE for convenience.
Definition: RippleState.h:39
ripple::RippleState::getAuthPeer
bool getAuthPeer() const
Definition: RippleState.h:83
ripple::RippleState::getQualityIn
Rate const & getQualityIn() const
Definition: RippleState.h:126
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:67
ripple::RippleState::getFreezePeer
bool getFreezePeer() const
Has the peer set the freeze flag on us.
Definition: RippleState.h:105
ripple::lsfLowAuth
@ lsfLowAuth
Definition: LedgerFormats.h:149
ripple::lsfLowNoRipple
@ lsfLowNoRipple
Definition: LedgerFormats.h:151
ripple::RippleState::highQualityOut_
Rate highQualityOut_
Definition: RippleState.h:155
std::vector
STL class.
ripple::RippleState::mLowID
AccountID const & mLowID
Definition: RippleState.h:149
ripple::RippleState::getAuth
bool getAuth() const
Definition: RippleState.h:78
ripple::lsfHighAuth
@ lsfHighAuth
Definition: LedgerFormats.h:150
ripple::RippleState::highQualityIn_
Rate highQualityIn_
Definition: RippleState.h:154
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:115
ripple::RippleState::getAccountIDPeer
AccountID const & getAccountIDPeer() const
Definition: RippleState.h:72
ripple::RippleState::~RippleState
virtual ~RippleState()=default
ripple::RippleState::sle_
std::shared_ptr< SLE const > sle_
Definition: RippleState.h:140
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:132
ripple::RippleState::getNoRipple
bool getNoRipple() const
Definition: RippleState.h:88
ripple::RippleState::getFreeze
bool getFreeze() const
Have we set the freeze flag on our peer.
Definition: RippleState.h:99
ripple::STAmount
Definition: STAmount.h:42
ripple::RippleState::getNoRipplePeer
bool getNoRipplePeer() const
Definition: RippleState.h:93
ripple::RippleState::mHighLimit
STAmount const & mHighLimit
Definition: RippleState.h:147
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:60
memory
ripple::lsfHighNoRipple
@ lsfHighNoRipple
Definition: LedgerFormats.h:152
ripple::lsfHighFreeze
@ lsfHighFreeze
Definition: LedgerFormats.h:154
ripple::RippleState::mLowLimit
STAmount const & mLowLimit
Definition: RippleState.h:146
ripple::RippleState::lowQualityIn_
Rate lowQualityIn_
Definition: RippleState.h:152
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:186
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:110
ripple::RippleState::RippleState
RippleState()=delete
ripple::RippleState::mBalance
STAmount mBalance
Definition: RippleState.h:157
ripple::lsfLowFreeze
@ lsfLowFreeze
Definition: LedgerFormats.h:153
ripple::RippleState::mViewLowest
bool mViewLowest
Definition: RippleState.h:142
ripple::RippleState::mHighID
AccountID const & mHighID
Definition: RippleState.h:150
ripple::RippleState::getLimitPeer
STAmount const & getLimitPeer() const
Definition: RippleState.h:120
ripple::RippleState::mFlags
std::uint32_t mFlags
Definition: RippleState.h:144
Json::Value
Represents a JSON value.
Definition: json_value.h:141