本文整理汇总了C++中LedgerKey::trustLine方法的典型用法代码示例。如果您正苦于以下问题:C++ LedgerKey::trustLine方法的具体用法?C++ LedgerKey::trustLine怎么用?C++ LedgerKey::trustLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LedgerKey
的用法示例。
在下文中一共展示了LedgerKey::trustLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: if
void
TrustFrame::getKeyFields(LedgerKey const& key, std::string& actIDStrKey,
std::string& issuerStrKey, std::string& assetCode)
{
actIDStrKey = PubKeyUtils::toStrKey(key.trustLine().accountID);
if (key.trustLine().asset.type() == ASSET_TYPE_CREDIT_ALPHANUM4)
{
issuerStrKey =
PubKeyUtils::toStrKey(key.trustLine().asset.alphaNum4().issuer);
assetCodeToStr(key.trustLine().asset.alphaNum4().assetCode, assetCode);
}
else if (key.trustLine().asset.type() == ASSET_TYPE_CREDIT_ALPHANUM12)
{
issuerStrKey =
PubKeyUtils::toStrKey(key.trustLine().asset.alphaNum12().issuer);
assetCodeToStr(key.trustLine().asset.alphaNum12().assetCode, assetCode);
}
if (actIDStrKey == issuerStrKey)
throw std::runtime_error("Issuer's own trustline should not be used "
"outside of OperationFrame");
}
示例3: runtime_error
TrustFrame::pointer
TrustFrame::loadTrustLine(AccountID const& accountID, Asset const& asset,
Database& db)
{
if (asset.type() == ASSET_TYPE_NATIVE)
{
throw std::runtime_error("XLM TrustLine?");
}
else
{
if (accountID == getIssuer(asset))
{
return createIssuerFrame(asset);
}
}
LedgerKey key;
key.type(TRUSTLINE);
key.trustLine().accountID = accountID;
key.trustLine().asset = asset;
if (cachedEntryExists(key, db))
{
auto p = getCachedEntry(key, db);
return p ? std::make_shared<TrustFrame>(*p) : nullptr;
}
std::string accStr, issuerStr, assetStr;
accStr = PubKeyUtils::toStrKey(accountID);
if (asset.type() == ASSET_TYPE_CREDIT_ALPHANUM4)
{
assetCodeToStr(asset.alphaNum4().assetCode, assetStr);
issuerStr = PubKeyUtils::toStrKey(asset.alphaNum4().issuer);
}
else if (asset.type() == ASSET_TYPE_CREDIT_ALPHANUM12)
{
assetCodeToStr(asset.alphaNum12().assetCode, assetStr);
issuerStr = PubKeyUtils::toStrKey(asset.alphaNum12().issuer);
}
auto query = std::string(trustLineColumnSelector);
query += (" WHERE accountid = :id "
" AND issuer = :issuer "
" AND assetcode = :asset");
auto prep = db.getPreparedStatement(query);
auto& st = prep.statement();
st.exchange(use(accStr));
st.exchange(use(issuerStr));
st.exchange(use(assetStr));
pointer retLine;
auto timer = db.getSelectTimer("trust");
loadLines(prep, [&retLine](LedgerEntry const& trust)
{
retLine = make_shared<TrustFrame>(trust);
});
if (retLine)
{
retLine->putCachedEntry(db);
}
else
{
putCachedEntry(key, nullptr, db);
}
return retLine;
}