20 #include <ripple/app/tx/impl/OfferStream.h>
21 #include <ripple/basics/Log.h>
27 checkIssuers(ReadView
const& view, Book
const& book)
29 auto issuerExists = [](ReadView
const& view, Issue
const& iss) ->
bool {
32 return issuerExists(view, book.in) && issuerExists(view, book.out);
36 template <
class TIn,
class TOut>
46 , cancelView_(cancelView)
48 , validBook_(checkIssuers(view, book))
58 template<
class TIn,
class TOut>
66 auto p = view.
peek (keylet::page(tip_.dir()));
71 "Missing directory " << tip_.dir() <<
72 " for offer " << tip_.index();
77 auto it (
std::find (v.begin(), v.end(), tip_.index()));
82 "Missing offer " << tip_.index() <<
83 " for directory " << tip_.dir();
92 "Missing offer " << tip_.index() <<
93 " removed from directory " << tip_.dir();
104 return accountFunds (view,
id, saDefault, freezeHandling, j);
119 return toAmount<IOUAmount> (
131 return toAmount<XRPAmount> (
135 template<
class TIn,
class TOut>
147 ownerFunds_ = boost::none;
156 if (!counter_.step ())
171 tp{d{(*entry)[sfExpiration]}} <= expire_)
174 "Removing expired offer " << entry->key();
175 permRmOffer (entry->key());
181 auto const amount (offer_.amount());
187 "Removing bad offer " << entry->key();
188 permRmOffer (entry->key());
198 if (*ownerFunds_ <= beast::zero)
203 auto const original_funds =
207 if (original_funds == *ownerFunds_)
209 permRmOffer (entry->key());
211 "Removing unfunded offer " << entry->key();
216 "Removing became unfunded offer " << entry->key();
229 OfferStream::permRmOffer (
uint256 const& offerIndex)
232 cancelView_.peek(keylet::offer(offerIndex)), j_);
235 template<
class TIn,
class TOut>
238 permToRemove_.insert (offerIndex);
A currency issued by an account.
Presents and consumes the offers in an order book.
Stream trace() const
Severity stream access functions.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
Floating point representation of amounts with high dynamic range.
FreezeHandling
Controls the treatment of frozen account balances.
Writeable view to a ledger, for applying a transaction.
void erase(STObject &st, TypedField< U > const &f)
Remove a field in an STObject.
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
static const account_t account
TOfferStreamBase(ApplyView &view, ApplyView &cancelView, Book const &book, NetClock::time_point when, StepCounter &counter, beast::Journal journal)
bool isXRP(AccountID const &c)
A generic endpoint for log messages.
const SF_Vec256 sfIndexes(access, STI_VECTOR256, 1, "Indexes", SField::sMD_Never)
const SF_U32 sfExpiration(access, STI_UINT32, 10, "Expiration")
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static STAmount accountFundsHelper(ReadView const &view, AccountID const &id, STAmount const &saDefault, Issue const &, FreezeHandling freezeHandling, beast::Journal j)