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


C++ LedgerKey::offer方法代码示例

本文整理汇总了C++中LedgerKey::offer方法的典型用法代码示例。如果您正苦于以下问题:C++ LedgerKey::offer方法的具体用法?C++ LedgerKey::offer怎么用?C++ LedgerKey::offer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LedgerKey的用法示例。


在下文中一共展示了LedgerKey::offer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadOffers

std::shared_ptr<LedgerEntry const>
LedgerStateRoot::Impl::loadOffer(LedgerKey const& key) const
{
    uint64_t offerID = key.offer().offerID;
    std::string actIDStrKey = KeyUtils::toStrKey(key.offer().sellerID);

    std::string sql = "SELECT sellerid, offerid, "
                      "sellingassettype, sellingassetcode, sellingissuer, "
                      "buyingassettype, buyingassetcode, buyingissuer, "
                      "amount, pricen, priced, flags, lastmodified "
                      "FROM offers "
                      "WHERE sellerid= :id AND offerid= :offerid";
    auto prep = mDatabase.getPreparedStatement(sql);
    auto& st = prep.statement();
    st.exchange(soci::use(actIDStrKey));
    st.exchange(soci::use(offerID));

    std::vector<LedgerEntry> offers;
    {
        auto timer = mDatabase.getSelectTimer("offer");
        offers = loadOffers(prep);
    }

    return offers.size() == 0
               ? nullptr
               : std::make_shared<LedgerEntry const>(offers.front());
}
开发者ID:graydon,项目名称:stellar-core,代码行数:27,代码来源:LedgerStateOfferSQL.cpp

示例2: EXISTS

bool
OfferFrame::exists(Database& db, LedgerKey const& key)
{
    std::string actIDStrKey = PubKeyUtils::toStrKey(key.offer().sellerID);
    int exists = 0;
    auto timer = db.getSelectTimer("offer-exists");
    db.getSession() << "SELECT EXISTS (SELECT NULL FROM offers "
                       "WHERE sellerid=:id AND offerid=:s)",
        use(actIDStrKey), use(key.offer().offerID), into(exists);
    return exists != 0;
}
开发者ID:themusicgod1,项目名称:stellar-core,代码行数:11,代码来源:OfferFrame.cpp

示例3: switch

LedgerKey
LedgerEntryKey(LedgerEntry const& e)
{
    auto& d = e.data;
    LedgerKey k;
    switch (d.type())
    {

    case ACCOUNT:
        k.type(ACCOUNT);
        k.account().accountID = d.account().accountID;
        break;

    case TRUSTLINE:
        k.type(TRUSTLINE);
        k.trustLine().accountID = d.trustLine().accountID;
        k.trustLine().asset = d.trustLine().asset;
        break;

    case OFFER:
        k.type(OFFER);
        k.offer().sellerID = d.offer().sellerID;
        k.offer().offerID = d.offer().offerID;
        break;

    case DATA:
        k.type(DATA);
        k.data().accountID = d.data().accountID;
        k.data().dataName = d.data().dataName;
        break;
    }
    return k;
}
开发者ID:stellar,项目名称:stellar-core,代码行数:33,代码来源:types.cpp

示例4: EXISTS

bool
OfferFrame::exists(Database& db, LedgerKey const& key)
{
    std::string actIDStrKey = PubKeyUtils::toStrKey(key.offer().sellerID);
    int exists = 0;
    auto timer = db.getSelectTimer("offer-exists");
    auto prep =
        db.getPreparedStatement("SELECT EXISTS (SELECT NULL FROM offers "
                                "WHERE sellerid=:id AND offerid=:s)");
    auto& st = prep.statement();
    st.exchange(use(actIDStrKey));
    st.exchange(use(key.offer().offerID));
    st.exchange(into(exists));
    st.define_and_bind();
    st.execute(true);
    return exists != 0;
}
开发者ID:tctx,项目名称:network,代码行数:17,代码来源:OfferFrame.cpp

示例5: use

void
OfferFrame::storeDelete(LedgerDelta& delta, Database& db, LedgerKey const& key)
{
    auto timer = db.getDeleteTimer("offer");

    db.getSession() << "DELETE FROM offers WHERE offerid=:s",
        use(key.offer().offerID);

    delta.deleteEntry(key);
}
开发者ID:themusicgod1,项目名称:stellar-core,代码行数:10,代码来源:OfferFrame.cpp

示例6:

void
OfferFrame::storeDelete(LedgerDelta& delta, Database& db, LedgerKey const& key)
{
    auto timer = db.getDeleteTimer("offer");
    auto prep = db.getPreparedStatement("DELETE FROM offers WHERE offerid=:s");
    auto& st = prep.statement();
    st.exchange(use(key.offer().offerID));
    st.define_and_bind();
    st.execute(true);
    delta.deleteEntry(key);
}
开发者ID:tctx,项目名称:network,代码行数:11,代码来源:OfferFrame.cpp

示例7: runtime_error

void
LedgerStateRoot::Impl::deleteOffer(LedgerKey const& key)
{
    auto const& offer = key.offer();

    auto prep =
        mDatabase.getPreparedStatement("DELETE FROM offers WHERE offerid=:s");
    auto& st = prep.statement();
    st.exchange(soci::use(offer.offerID));
    st.define_and_bind();
    {
        auto timer = mDatabase.getDeleteTimer("offer");
        st.execute(true);
    }
    if (st.get_affected_rows() != 1)
    {
        throw std::runtime_error("Could not update data in SQL");
    }
}
开发者ID:graydon,项目名称:stellar-core,代码行数:19,代码来源:LedgerStateOfferSQL.cpp


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