本文整理汇总了C++中Currency::alphaNum方法的典型用法代码示例。如果您正苦于以下问题:C++ Currency::alphaNum方法的具体用法?C++ Currency::alphaNum怎么用?C++ Currency::alphaNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::alphaNum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strToCurrencyCode
Currency
makeCurrency(SecretKey& issuer, std::string const& code)
{
Currency currency;
currency.type(CURRENCY_TYPE_ALPHANUM);
currency.alphaNum().issuer = issuer.getPublicKey();
strToCurrencyCode(currency.alphaNum().currencyCode, code);
return currency;
}
示例2: innerResult
bool
AllowTrustOpFrame::doCheckValid()
{
if (mAllowTrust.currency.type() != CURRENCY_TYPE_ALPHANUM)
{
innerResult().code(ALLOW_TRUST_MALFORMED);
return false;
}
Currency ci;
ci.type(CURRENCY_TYPE_ALPHANUM);
ci.alphaNum().currencyCode = mAllowTrust.currency.currencyCode();
ci.alphaNum().issuer = getSourceID();
if (!isCurrencyValid(ci))
{
innerResult().code(ALLOW_TRUST_MALFORMED);
return false;
}
return true;
}
示例3: oe
//.........这里部分代码省略.........
{
innerResult().multi().last =
SimplePaymentResult(destination.getID(), curB, curBReceived);
}
}
if (multi_mode)
{
// now, walk the path backwards
for (int i = (int)mPayment.path.size() - 1; i >= 0; i--)
{
int64_t curASent, actualCurBReceived;
Currency const& curA = mPayment.path[i];
OfferExchange oe(delta, ledgerManager);
// curA -> curB
OfferExchange::ConvertResult r =
oe.convertWithOffers(curA, INT64_MAX, curASent, curB,
curBReceived, actualCurBReceived, nullptr);
switch (r)
{
case OfferExchange::eFilterStop:
assert(false); // no filter -> should not happen
break;
case OfferExchange::eOK:
if (curBReceived == actualCurBReceived)
{
break;
}
// fall through
case OfferExchange::ePartial:
innerResult().code(PAYMENT_TOO_FEW_OFFERS);
return false;
}
assert(curBReceived == actualCurBReceived);
curBReceived = curASent; // next round, we need to send enough
curB = curA;
// add offers that got taken on the way
// insert in front to match the path's order
auto& offers = innerResult().multi().offers;
offers.insert(offers.begin(), oe.getOfferTrail().begin(),
oe.getOfferTrail().end());
}
}
// last step: we've reached the first account in the chain, update its
// balance
int64_t curBSent;
curBSent = curBReceived;
if (curBSent > mPayment.sendMax)
{ // make sure not over the max
innerResult().code(PAYMENT_OVER_SENDMAX);
return false;
}
if (curB.type() == CURRENCY_TYPE_NATIVE)
{
int64_t minBalance = mSourceAccount->getMinimumBalance(ledgerManager);
if (mSourceAccount->getAccount().balance < (minBalance + curBSent))
{ // they don't have enough to send
innerResult().code(PAYMENT_UNDERFUNDED);
return false;
}
mSourceAccount->getAccount().balance -= curBSent;
mSourceAccount->storeChange(delta, db);
}
else
{
AccountFrame issuer;
if (!AccountFrame::loadAccount(curB.alphaNum().issuer, issuer, db))
{
throw std::runtime_error("sendCredit Issuer not found");
}
TrustFrame sourceLineFrame;
if (!TrustFrame::loadTrustLine(getSourceID(), curB, sourceLineFrame,
db))
{
innerResult().code(PAYMENT_UNDERFUNDED);
return false;
}
if (!sourceLineFrame.addBalance(-curBSent))
{
innerResult().code(PAYMENT_UNDERFUNDED);
return false;
}
sourceLineFrame.storeChange(delta, db);
}
return true;
}
示例4: oe
//.........这里部分代码省略.........
case OfferExchange::eOK:
if (curBReceived == actualCurBReceived)
{
break;
}
// fall through
case OfferExchange::ePartial:
metrics.NewMeter({"op-path-payment", "failure", "too-few-offers"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_TOO_FEW_OFFERS);
return false;
}
assert(curBReceived == actualCurBReceived);
curBReceived = curASent; // next round, we need to send enough
curB = curA;
// add offers that got taken on the way
// insert in front to match the path's order
auto& offers = innerResult().success().offers;
offers.insert(offers.begin(), oe.getOfferTrail().begin(),
oe.getOfferTrail().end());
}
// last step: we've reached the first account in the chain, update its
// balance
int64_t curBSent;
curBSent = curBReceived;
if (curBSent > mPathPayment.sendMax)
{ // make sure not over the max
metrics.NewMeter({"op-path-payment", "failure", "over-send-max"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_OVER_SENDMAX);
return false;
}
if (curB.type() == CURRENCY_TYPE_NATIVE)
{
int64_t minBalance = mSourceAccount->getMinimumBalance(ledgerManager);
if ((mSourceAccount->getAccount().balance - curBSent) < minBalance)
{ // they don't have enough to send
metrics.NewMeter({"op-path-payment", "failure", "underfunded"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_UNDERFUNDED);
return false;
}
mSourceAccount->getAccount().balance -= curBSent;
mSourceAccount->storeChange(delta, db);
}
else
{
AccountFrame::pointer issuer;
issuer = AccountFrame::loadAccount(curB.alphaNum().issuer, db);
if (!issuer)
{
metrics.NewMeter({"op-path-payment", "failure", "no-issuer"},
"operation").Mark();
throw std::runtime_error("sendCredit Issuer not found");
}
TrustFrame::pointer sourceLineFrame;
sourceLineFrame = TrustFrame::loadTrustLine(getSourceID(), curB, db);
if (!sourceLineFrame)
{
metrics.NewMeter({"op-path-payment", "failure", "src-no-trust"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_SRC_NO_TRUST);
return false;
}
if (!sourceLineFrame->isAuthorized())
{
metrics.NewMeter(
{"op-path-payment", "failure", "src-not-authorized"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_SRC_NOT_AUTHORIZED);
return false;
}
if (!sourceLineFrame->addBalance(-curBSent))
{
metrics.NewMeter({"op-path-payment", "failure", "underfunded"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_UNDERFUNDED);
return false;
}
sourceLineFrame->storeChange(delta, db);
}
metrics.NewMeter({"op-path-payment", "success", "apply"}, "operation")
.Mark();
return true;
}