本文整理汇总了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());
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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");
}
}