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()));
70 JLOG(j_.
error()) <<
"Missing directory " << tip_.dir() <<
" for offer "
76 auto it(
std::find(v.begin(), v.end(), tip_.index()));
80 JLOG(j_.
error()) <<
"Missing offer " << tip_.index()
81 <<
" for directory " << tip_.dir();
89 JLOG(j_.
trace()) <<
"Missing offer " << tip_.index()
90 <<
" removed from directory " << tip_.dir();
102 return accountFunds(view,
id, saDefault, freezeHandling, j);
135 template <
class TIn,
class TOut>
147 ownerFunds_ = boost::none;
156 if (!counter_.step())
171 tp{d{(*entry)[sfExpiration]}} <= expire_)
173 JLOG(j_.
trace()) <<
"Removing expired offer " << entry->key();
174 permRmOffer(entry->key());
180 auto const amount(offer_.amount());
185 JLOG(j_.
warn()) <<
"Removing bad offer " << entry->key();
186 permRmOffer(entry->key());
201 if (*ownerFunds_ <= beast::zero)
214 if (original_funds == *ownerFunds_)
216 permRmOffer(entry->key());
217 JLOG(j_.
trace()) <<
"Removing unfunded offer " << entry->key();
222 <<
"Removing became unfunded offer " << entry->key();
235 OfferStream::permRmOffer(
uint256 const& offerIndex)
237 offerDelete(cancelView_, cancelView_.peek(keylet::offer(offerIndex)), j_);
240 template <
class TIn,
class TOut>
244 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.
Keylet account(AccountID const &id) noexcept
AccountID root.
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
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)