本文整理汇总了C++中sle::pointer::setAccountID方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::setAccountID方法的具体用法?C++ pointer::setAccountID怎么用?C++ pointer::setAccountID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sle::pointer
的用法示例。
在下文中一共展示了pointer::setAccountID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: target_account
TER
CreateTicket::doApply ()
{
auto const sle = view().peek(keylet::account(account_));
// A ticket counts against the reserve of the issuing account, but we
// check the starting balance because we want to allow dipping into the
// reserve to pay fees.
{
auto const reserve = view().fees().accountReserve(
sle->getFieldU32(sfOwnerCount) + 1);
if (mPriorBalance < reserve)
return tecINSUFFICIENT_RESERVE;
}
NetClock::time_point expiration{};
if (ctx_.tx.isFieldPresent (sfExpiration))
{
expiration = NetClock::time_point(NetClock::duration(ctx_.tx[sfExpiration]));
if (view().parentCloseTime() >= expiration)
return tesSUCCESS;
}
SLE::pointer sleTicket = std::make_shared<SLE>(ltTICKET,
getTicketIndex (account_, ctx_.tx.getSequence ()));
sleTicket->setAccountID (sfAccount, account_);
sleTicket->setFieldU32 (sfSequence, ctx_.tx.getSequence ());
if (expiration != NetClock::time_point{})
sleTicket->setFieldU32 (sfExpiration, expiration.time_since_epoch().count());
view().insert (sleTicket);
if (ctx_.tx.isFieldPresent (sfTarget))
{
AccountID const target_account (ctx_.tx.getAccountID (sfTarget));
SLE::pointer sleTarget = view().peek (keylet::account(target_account));
// Destination account does not exist.
if (!sleTarget)
return tecNO_TARGET;
// The issuing account is the default account to which the ticket
// applies so don't bother saving it if that's what's specified.
if (target_account != account_)
sleTicket->setAccountID (sfTarget, target_account);
}
auto viewJ = ctx_.app.journal ("View");
auto const page = dirAdd(view(), keylet::ownerDir (account_),
sleTicket->key(), false, describeOwnerDir (account_), viewJ);
JLOG(j_.trace()) <<
"Creating ticket " << to_string (sleTicket->key()) <<
": " << (page ? "success" : "failure");
if (!page)
return tecDIR_FULL;
sleTicket->setFieldU64(sfOwnerNode, *page);
// If we succeeded, the new entry counts against the
// creator's reserve.
adjustOwnerCount(view(), sle, 1, viewJ);
return tesSUCCESS;
}