本文整理汇总了C++中accountframe::pointer::getID方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::getID方法的具体用法?C++ pointer::getID怎么用?C++ pointer::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accountframe::pointer
的用法示例。
在下文中一共展示了pointer::getID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invalid_argument
void
TransactionFrame::setSourceAccountPtr(AccountFrame::pointer signingAccount)
{
if (!signingAccount)
{
if (mEnvelope.tx.sourceAccount != signingAccount->getID())
{
throw std::invalid_argument("wrong account");
}
}
mSigningAccount = signingAccount;
}
示例2: runtime_error
//.........这里部分代码省略.........
// actual update
// is done further down
sellingWheatOffer.getOffer().amount = numWheatReceived;
}
bool reducedOffer = false;
if (numWheatReceived > maxWheatReceived)
{
numWheatReceived = maxWheatReceived;
reducedOffer = true;
}
// this guy can get X wheat to you. How many sheep does that get him?
if (!bigDivide(numSheepSend, numWheatReceived,
sellingWheatOffer.getOffer().price.n,
sellingWheatOffer.getOffer().price.d))
{
numSheepSend = INT64_MAX;
}
if (numSheepSend > maxSheepSend)
{
// reduce the number even more if there is a limit on Sheep
numSheepSend = maxSheepSend;
reducedOffer = true;
}
// bias towards seller (this cannot overflow at this point)
numWheatReceived =
bigDivide(numSheepSend, sellingWheatOffer.getOffer().price.d,
sellingWheatOffer.getOffer().price.n);
bool offerTaken = false;
if (numWheatReceived == 0 || numSheepSend == 0)
{
if (reducedOffer)
{
return eOfferCantConvert;
}
else
{
// force delete the offer as it represents a bogus offer
numWheatReceived = 0;
numSheepSend = 0;
offerTaken = true;
}
}
offerTaken =
offerTaken || sellingWheatOffer.getOffer().amount <= numWheatReceived;
if (offerTaken)
{ // entire offer is taken
sellingWheatOffer.storeDelete(mDelta, db);
accountB->addNumEntries(-1, mLedgerManager);
accountB->storeChange(mDelta, db);
}
else
{
sellingWheatOffer.getOffer().amount -= numWheatReceived;
sellingWheatOffer.storeChange(mDelta, db);
}
// Adjust balances
if (sheep.type() == ASSET_TYPE_NATIVE)
{
accountB->getAccount().balance += numSheepSend;
accountB->storeChange(mDelta, db);
}
else
{
if (!sheepLineAccountB->addBalance(numSheepSend))
{
return eOfferCantConvert;
}
sheepLineAccountB->storeChange(mDelta, db);
}
if (wheat.type() == ASSET_TYPE_NATIVE)
{
accountB->getAccount().balance -= numWheatReceived;
accountB->storeChange(mDelta, db);
}
else
{
if (!wheatLineAccountB->addBalance(-numWheatReceived))
{
return eOfferCantConvert;
}
wheatLineAccountB->storeChange(mDelta, db);
}
mOfferTrail.push_back(
ClaimOfferAtom(accountB->getID(), sellingWheatOffer.getOfferID(), wheat,
numWheatReceived, sheep, numSheepSend));
return offerTaken ? eOfferTaken : eOfferPartial;
}
示例3: oe
bool
PathPaymentOpFrame::doApply(medida::MetricsRegistry& metrics,
LedgerDelta& delta, LedgerManager& ledgerManager)
{
AccountFrame::pointer destination;
Database& db = ledgerManager.getDatabase();
destination = AccountFrame::loadAccount(mPathPayment.destination, db);
if (!destination)
{
metrics.NewMeter({"op-path-payment", "failure", "no-destination"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_NO_DESTINATION);
return false;
}
innerResult().code(PATH_PAYMENT_SUCCESS);
// tracks the last amount that was traded
int64_t curBReceived = mPathPayment.destAmount;
Asset curB = mPathPayment.destAsset;
// update balances, walks backwards
// build the full path to the destination, starting with sendAsset
std::vector<Asset> fullPath;
fullPath.emplace_back(mPathPayment.sendAsset);
fullPath.insert(fullPath.end(), mPathPayment.path.begin(),
mPathPayment.path.end());
// update last balance in the chain
{
if (curB.type() == ASSET_TYPE_NATIVE)
{
destination->getAccount().balance += curBReceived;
destination->storeChange(delta, db);
}
else
{
TrustFrame::pointer destLine;
destLine =
TrustFrame::loadTrustLine(destination->getID(), curB, db);
if (!destLine)
{
metrics.NewMeter({"op-path-payment", "failure", "no-trust"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_NO_TRUST);
return false;
}
if (!destLine->isAuthorized())
{
metrics.NewMeter(
{"op-path-payment", "failure", "not-authorized"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_NOT_AUTHORIZED);
return false;
}
if (!destLine->addBalance(curBReceived))
{
metrics.NewMeter({"op-path-payment", "failure", "line-full"},
"operation").Mark();
innerResult().code(PATH_PAYMENT_LINE_FULL);
return false;
}
destLine->storeChange(delta, db);
}
innerResult().success().last =
SimplePaymentResult(destination->getID(), curB, curBReceived);
}
// now, walk the path backwards
for (int i = (int)fullPath.size() - 1; i >= 0; i--)
{
int64_t curASent, actualCurBReceived;
Asset const& curA = fullPath[i];
if (curA == curB)
{
continue;
}
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:
//.........这里部分代码省略.........