本文整理汇总了C++中STAmount::zeroed方法的典型用法代码示例。如果您正苦于以下问题:C++ STAmount::zeroed方法的具体用法?C++ STAmount::zeroed怎么用?C++ STAmount::zeroed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STAmount
的用法示例。
在下文中一共展示了STAmount::zeroed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeReverseLiquidityForAccount
TER computeReverseLiquidityForAccount (
RippleCalc& rippleCalc,
const unsigned int nodeIndex, PathState& pathState,
const bool bMultiQuality)
{
TER terResult = tesSUCCESS;
auto const lastNodeIndex = pathState.nodes().size () - 1;
auto const isFinalNode = (nodeIndex == lastNodeIndex);
// 0 quality means none has yet been determined.
std::uint64_t uRateMax = 0;
auto& previousNode = pathState.nodes()[nodeIndex ? nodeIndex - 1 : 0];
auto& node = pathState.nodes()[nodeIndex];
auto& nextNode = pathState.nodes()[isFinalNode ? lastNodeIndex : nodeIndex + 1];
// Current is allowed to redeem to next.
const bool previousNodeIsAccount = !nodeIndex || previousNode.isAccount();
const bool nextNodeIsAccount = isFinalNode || nextNode.isAccount();
Account const& previousAccountID = previousNodeIsAccount
? previousNode.account_ : node.account_;
Account const& nextAccountID = nextNodeIsAccount ? nextNode.account_
: node.account_; // Offers are always issue.
// This is the quality from from the previous node to this one.
const std::uint32_t uQualityIn
= (nodeIndex != 0)
? rippleCalc.mActiveLedger.rippleQualityIn (
node.account_, previousAccountID, node.currency_)
: QUALITY_ONE;
// And this is the quality from the next one to this one.
const std::uint32_t uQualityOut
= (nodeIndex != lastNodeIndex)
? rippleCalc.mActiveLedger.rippleQualityOut (
node.account_, nextAccountID, node.currency_)
: QUALITY_ONE;
// For previousNodeIsAccount:
// Previous account is already owed.
const STAmount saPrvOwed = (previousNodeIsAccount && nodeIndex != 0)
? rippleCalc.mActiveLedger.rippleOwed (
node.account_, previousAccountID, node.currency_)
: STAmount ({node.currency_, node.account_});
// The limit amount that the previous account may owe.
const STAmount saPrvLimit = (previousNodeIsAccount && nodeIndex != 0)
? rippleCalc.mActiveLedger.rippleLimit (
node.account_, previousAccountID, node.currency_)
: STAmount ({node.currency_, node.account_});
// Next account is owed.
const STAmount saNxtOwed = (nextNodeIsAccount && nodeIndex != lastNodeIndex)
? rippleCalc.mActiveLedger.rippleOwed (
node.account_, nextAccountID, node.currency_)
: STAmount ({node.currency_, node.account_});
WriteLog (lsTRACE, RippleCalc)
<< "computeReverseLiquidityForAccount>"
<< " nodeIndex=%d/%d" << nodeIndex << "/" << lastNodeIndex
<< " previousAccountID=" << previousAccountID
<< " node.account_=" << node.account_
<< " nextAccountID=" << nextAccountID
<< " currency_=" << node.currency_
<< " uQualityIn=" << uQualityIn
<< " uQualityOut=" << uQualityOut
<< " saPrvOwed=" << saPrvOwed
<< " saPrvLimit=" << saPrvLimit;
// Requests are computed to be the maximum flow possible.
// Previous can redeem the owed IOUs it holds.
const STAmount saPrvRedeemReq = (saPrvOwed > zero)
? saPrvOwed
: STAmount (saPrvOwed.issue ());
// This is the amount we're actually going to be setting for the previous
// node.
STAmount& saPrvRedeemAct = previousNode.saRevRedeem;
// Previous can issue up to limit minus whatever portion of limit already
// used (not including redeemable amount) - another "maximum flow".
const STAmount saPrvIssueReq = (saPrvOwed < zero)
? saPrvLimit + saPrvOwed : saPrvLimit;
STAmount& saPrvIssueAct = previousNode.saRevIssue;
// Precompute these values in case we have an order book.
auto deliverCurrency = previousNode.saRevDeliver.getCurrency ();
const STAmount saPrvDeliverReq (
{deliverCurrency, previousNode.saRevDeliver.getIssuer ()}, -1);
// Unlimited delivery.
STAmount& saPrvDeliverAct = previousNode.saRevDeliver;
// For nextNodeIsAccount
const STAmount& saCurRedeemReq = node.saRevRedeem;
// Set to zero, because we're trying to hit the previous node.
auto saCurRedeemAct = saCurRedeemReq.zeroed();
//.........这里部分代码省略.........
示例2: reverseLiquidityForAccount
TER PathCursor::reverseLiquidityForAccount () const
{
TER terResult = tesSUCCESS;
auto const lastNodeIndex = nodeSize () - 1;
auto const isFinalNode = (nodeIndex_ == lastNodeIndex);
// 0 quality means none has yet been determined.
std::uint64_t uRateMax = 0;
// Current is allowed to redeem to next.
const bool previousNodeIsAccount = !nodeIndex_ ||
previousNode().isAccount();
const bool nextNodeIsAccount = isFinalNode || nextNode().isAccount();
AccountID const& previousAccountID = previousNodeIsAccount
? previousNode().account_ : node().account_;
AccountID const& nextAccountID = nextNodeIsAccount ? nextNode().account_
: node().account_; // Offers are always issue.
// This is the quality from from the previous node to this one.
auto const qualityIn
= (nodeIndex_ != 0)
? quality_in (view(),
node().account_,
previousAccountID,
node().issue_.currency)
: parityRate;
// And this is the quality from the next one to this one.
auto const qualityOut
= (nodeIndex_ != lastNodeIndex)
? quality_out (view(),
node().account_,
nextAccountID,
node().issue_.currency)
: parityRate;
// For previousNodeIsAccount:
// Previous account is already owed.
const STAmount saPrvOwed = (previousNodeIsAccount && nodeIndex_ != 0)
? creditBalance (view(),
node().account_,
previousAccountID,
node().issue_.currency)
: STAmount (node().issue_);
// The limit amount that the previous account may owe.
const STAmount saPrvLimit = (previousNodeIsAccount && nodeIndex_ != 0)
? creditLimit (view(),
node().account_,
previousAccountID,
node().issue_.currency)
: STAmount (node().issue_);
// Next account is owed.
const STAmount saNxtOwed = (nextNodeIsAccount && nodeIndex_ != lastNodeIndex)
? creditBalance (view(),
node().account_,
nextAccountID,
node().issue_.currency)
: STAmount (node().issue_);
JLOG (j_.trace())
<< "reverseLiquidityForAccount>"
<< " nodeIndex_=" << nodeIndex_ << "/" << lastNodeIndex
<< " previousAccountID=" << previousAccountID
<< " node.account_=" << node().account_
<< " nextAccountID=" << nextAccountID
<< " currency=" << node().issue_.currency
<< " qualityIn=" << qualityIn
<< " qualityOut=" << qualityOut
<< " saPrvOwed=" << saPrvOwed
<< " saPrvLimit=" << saPrvLimit;
// Requests are computed to be the maximum flow possible.
// Previous can redeem the owed IOUs it holds.
const STAmount saPrvRedeemReq = (saPrvOwed > beast::zero)
? saPrvOwed
: STAmount (saPrvOwed.issue ());
// Previous can issue up to limit minus whatever portion of limit already
// used (not including redeemable amount) - another "maximum flow".
const STAmount saPrvIssueReq = (saPrvOwed < beast::zero)
? saPrvLimit + saPrvOwed : saPrvLimit;
// Precompute these values in case we have an order book.
auto deliverCurrency = previousNode().saRevDeliver.getCurrency ();
const STAmount saPrvDeliverReq (
{deliverCurrency, previousNode().saRevDeliver.getIssuer ()}, -1);
// -1 means unlimited delivery.
// Set to zero, because we're trying to hit the previous node.
auto saCurRedeemAct = node().saRevRedeem.zeroed();
// Track the amount we actually redeem.
auto saCurIssueAct = node().saRevIssue.zeroed();
// For !nextNodeIsAccount
auto saCurDeliverAct = node().saRevDeliver.zeroed();
//.........这里部分代码省略.........