当前位置: 首页>>代码示例>>C++>>正文


C++ Offer::amount方法代码示例

本文整理汇总了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);
}
开发者ID:Joke-Dk,项目名称:rippled,代码行数:26,代码来源:Taker27.cpp

示例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);
}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:12,代码来源:Taker.cpp

示例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);
}
开发者ID:luckfan,项目名称:vpal,代码行数:19,代码来源:Taker.cpp

示例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);
}
开发者ID:Joke-Dk,项目名称:rippled,代码行数:36,代码来源:Taker27.cpp

示例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);
}
开发者ID:Joke-Dk,项目名称:rippled,代码行数:17,代码来源:Taker27.cpp

示例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);
}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:21,代码来源:Taker.cpp


注:本文中的Offer::amount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。