本文整理汇总了C++中Offer::amount方法的典型用法代码示例。如果您正苦于以下问题:C++ Offer::amount方法的具体用法?C++ Offer::amount怎么用?C++ Offer::amount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Offer
的用法示例。
在下文中一共展示了Offer::amount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: limit
TER
Taker::cross (Offer const& offer)
{
assert (!done ());
/* Before we call flow we must set the limit right; for buy semantics we
need to clamp the output. And we always want to clamp the input.
*/
Amounts limit (offer.amount());
if (! m_options.sell)
limit = offer.quality ().ceil_out (limit, m_remain.out);
limit = offer.quality().ceil_in (limit, m_remain.in);
assert (limit.in <= offer.amount().in);
assert (limit.out <= offer.amount().out);
assert (limit.in <= m_remain.in);
Amounts const amount (flow (limit, offer, account ()));
m_remain.out -= amount.out;
m_remain.in -= amount.in;
assert (m_remain.in >= zero);
return fill (offer, amount);
}
示例2: fill
TER
Taker::cross (Offer const& offer)
{
// In direct crossings, at least one leg must not be XRP.
if (isXRP (offer.amount ().in) && isXRP (offer.amount ().out))
return tefINTERNAL;
auto const amount = do_cross (
offer.amount (), offer.quality (), offer.owner ());
return fill (amount, offer);
}
示例3: limit
TER
Taker::cross (Offer const& offer)
{
assert (!done ());
Amounts limit (offer.amount());
if (m_options.sell)
limit = offer.quality().ceil_in (limit, m_remain.in);
else
limit = offer.quality ().ceil_out (limit, m_remain.out);
assert (limit.out <= offer.amount().out);
assert (limit.in <= offer.amount().in);
Amounts const amount (flow (limit, offer, account ()));
m_remain.out -= amount.out;
m_remain.in -= amount.in;
assert (m_remain.in >= zero);
return fill (offer, amount);
}
示例4: fill
TER
Taker::cross (Offer const& leg1, Offer const& leg2)
{
assert (!done ());
assert (leg1.amount ().out.isNative ());
assert (leg2.amount ().in.isNative ());
Amounts amount1 (leg1.amount());
Amounts amount2 (leg2.amount());
if (m_options.sell)
amount1 = leg1.quality().ceil_in (amount1, m_remain.in);
else
amount2 = leg2.quality().ceil_out (amount2, m_remain.out);
if (amount1.out <= amount2.in)
amount2 = leg2.quality().ceil_in (amount2, amount1.out);
else
amount1 = leg1.quality().ceil_out (amount1, amount2.in);
assert (amount1.out == amount2.in);
// As written, flow can't handle a 3-party transfer, but this works for
// us because the output of leg1 and the input leg2 are XRP.
Amounts flow1 (flow (amount1, leg1, m_account));
amount2 = leg2.quality().ceil_in (amount2, flow1.out);
Amounts flow2 (flow (amount2, leg2, m_account));
m_remain.out -= amount2.out;
m_remain.in -= amount1.in;
return fill (leg1, flow1, leg2, flow2);
}
示例5: remaining
// Adjust an offer to indicate that we are consuming some (or all) of it.
void
Taker::consume (Offer const& offer, Amounts const& consumed) const
{
Amounts const& remaining (offer.amount ());
assert (remaining.in > zero && remaining.out > zero);
assert (remaining.in >= consumed.in && remaining.out >= consumed.out);
offer.entry ()->setFieldAmount (sfTakerPays, remaining.in - consumed.in);
offer.entry ()->setFieldAmount (sfTakerGets, remaining.out - consumed.out);
view ().entryModify (offer.entry());
assert (offer.entry ()->getFieldAmount (sfTakerPays) >= zero);
assert (offer.entry ()->getFieldAmount (sfTakerGets) >= zero);
}
示例6:
void
Taker::consume_offer (Offer const& offer, Amounts const& order)
{
if (order.in < zero)
Throw<std::logic_error> ("flow with negative input.");
if (order.out < zero)
Throw<std::logic_error> ("flow with negative output.");
if (journal_.debug) journal_.debug << "Consuming from offer " << offer;
if (journal_.trace)
{
auto const& available = offer.amount ();
journal_.trace << " in:" << format_amount (available.in);
journal_.trace << " out:" << format_amount(available.out);
}
offer.consume (view_, order);
}