本文整理汇总了C++中STAmount::getMantissa方法的典型用法代码示例。如果您正苦于以下问题:C++ STAmount::getMantissa方法的具体用法?C++ STAmount::getMantissa怎么用?C++ STAmount::getMantissa使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STAmount
的用法示例。
在下文中一共展示了STAmount::getMantissa方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doApply
TER PaymentTransactor::doApply ()
{
// Ripple if source or destination is non-native or if there are paths.
std::uint32_t const uTxFlags = mTxn.getFlags ();
//bool const bPartialPayment = is_bit_set(uTxFlags, tfPartialPayment);
bool const bLimitQuality = is_bit_set (uTxFlags, tfLimitQuality);
bool const bNoRippleDirect = is_bit_set (uTxFlags, tfNoRippleDirect);
bool const bPaths = mTxn.isFieldPresent (sfPaths);
bool const bMax = mTxn.isFieldPresent (sfSendMax);
uint160 const uDstAccountID = mTxn.getFieldAccount160 (sfDestination);
STAmount const saDstAmount = mTxn.getFieldAmount (sfAmount);
STAmount const saMaxAmount = bMax
? mTxn.getFieldAmount (sfSendMax)
: saDstAmount.isNative ()
? saDstAmount
: STAmount (saDstAmount.getCurrency (),
mTxnAccountID,
saDstAmount.getMantissa (),
saDstAmount.getExponent (),
saDstAmount < zero);
uint160 const uSrcCurrency = saMaxAmount.getCurrency ();
uint160 const uDstCurrency = saDstAmount.getCurrency ();
bool const bSTRDirect = uSrcCurrency.isZero () && uDstCurrency.isZero ();
m_journal.trace <<
"saMaxAmount=" << saMaxAmount.getFullText () <<
" saDstAmount=" << saDstAmount.getFullText ();
if (!saDstAmount.isLegalNet () || !saMaxAmount.isLegalNet ())
return temBAD_AMOUNT;
if (uTxFlags & tfPaymentMask)
{
m_journal.trace <<
"Malformed transaction: Invalid flags set.";
return temINVALID_FLAG;
}
else if (!uDstAccountID)
{
m_journal.trace <<
"Malformed transaction: Payment destination account not specified.";
return temDST_NEEDED;
}
else if (bMax && saMaxAmount <= zero)
{
m_journal.trace <<
"Malformed transaction: bad max amount: " << saMaxAmount.getFullText ();
return temBAD_AMOUNT;
}
else if (saDstAmount <= zero)
{
m_journal.trace <<
"Malformed transaction: bad dst amount: " << saDstAmount.getFullText ();
return temBAD_AMOUNT;
}
else if (CURRENCY_BAD == uSrcCurrency || CURRENCY_BAD == uDstCurrency)
{
m_journal.trace <<
"Malformed transaction: Bad currency.";
return temBAD_CURRENCY;
}
else if (mTxnAccountID == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths)
{
m_journal.trace <<
"Malformed transaction: Redundant transaction:" <<
" src=" << to_string (mTxnAccountID) <<
" dst=" << to_string (uDstAccountID) <<
" src_cur=" << to_string (uSrcCurrency) <<
" dst_cur=" << to_string (uDstCurrency);
return temREDUNDANT;
}
else if (bMax && saMaxAmount == saDstAmount && saMaxAmount.getCurrency () == saDstAmount.getCurrency ())
{
m_journal.trace <<
"Malformed transaction: Redundant SendMax.";
return temREDUNDANT_SEND_MAX;
}
else if (bSTRDirect && bMax)
{
m_journal.trace <<
"Malformed transaction: SendMax specified for STR to STR.";
return temBAD_SEND_STR_MAX;
}
else if (bSTRDirect && bPaths)
{
m_journal.trace <<
"Malformed transaction: Paths specified for STR to STR.";
return temBAD_SEND_STR_PATHS;
}
else if (bSTRDirect && bLimitQuality)
//.........这里部分代码省略.........
示例2: doApply
TER Payment::doApply ()
{
// Ripple if source or destination is non-native or if there are paths.
std::uint32_t const uTxFlags = mTxn.getFlags ();
bool const bPartialPayment (uTxFlags & tfPartialPayment);
bool const bLimitQuality (uTxFlags & tfLimitQuality);
bool const bNoRippleDirect (uTxFlags & tfNoRippleDirect);
bool const bPaths = mTxn.isFieldPresent (sfPaths);
bool const bMax = mTxn.isFieldPresent (sfSendMax);
Account const& uDstAccountID = mTxn.getFieldAccount160 (sfDestination);
STAmount const saDstAmount = mTxn.getFieldAmount (sfAmount);
STAmount maxSourceAmount;
if (bMax)
maxSourceAmount = mTxn.getFieldAmount (sfSendMax);
else if (saDstAmount.isNative ())
maxSourceAmount = saDstAmount;
else
maxSourceAmount = STAmount (
{saDstAmount.getCurrency (), mTxnAccountID},
saDstAmount.getMantissa (), saDstAmount.getExponent (),
saDstAmount < zero);
auto const& uSrcCurrency = maxSourceAmount.getCurrency ();
auto const& uDstCurrency = saDstAmount.getCurrency ();
// isZero() is XRP. FIX!
bool const bXRPDirect = uSrcCurrency.isZero () && uDstCurrency.isZero ();
m_journal.trace <<
"maxSourceAmount=" << maxSourceAmount.getFullText () <<
" saDstAmount=" << saDstAmount.getFullText ();
if (!saDstAmount.isLegalNet () || !maxSourceAmount.isLegalNet ())
return temBAD_AMOUNT;
if (uTxFlags & tfPaymentMask)
{
m_journal.trace <<
"Malformed transaction: Invalid flags set.";
return temINVALID_FLAG;
}
else if (!uDstAccountID)
{
m_journal.trace <<
"Malformed transaction: Payment destination account not specified.";
return temDST_NEEDED;
}
else if (bMax && maxSourceAmount <= zero)
{
m_journal.trace <<
"Malformed transaction: bad max amount: " << maxSourceAmount.getFullText ();
return temBAD_AMOUNT;
}
else if (saDstAmount <= zero)
{
m_journal.trace <<
"Malformed transaction: bad dst amount: " << saDstAmount.getFullText ();
return temBAD_AMOUNT;
}
else if (badCurrency() == uSrcCurrency || badCurrency() == uDstCurrency)
{
m_journal.trace <<
"Malformed transaction: Bad currency.";
return temBAD_CURRENCY;
}
else if (mTxnAccountID == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths)
{
// You're signing yourself a payment.
// If bPaths is true, you might be trying some arbitrage.
m_journal.trace <<
"Malformed transaction: Redundant transaction:" <<
" src=" << to_string (mTxnAccountID) <<
" dst=" << to_string (uDstAccountID) <<
" src_cur=" << to_string (uSrcCurrency) <<
" dst_cur=" << to_string (uDstCurrency);
return temREDUNDANT;
}
else if (bMax && maxSourceAmount == saDstAmount &&
maxSourceAmount.getCurrency () == saDstAmount.getCurrency ())
{
// Consistent but redundant transaction.
m_journal.trace <<
"Malformed transaction: Redundant SendMax.";
return temREDUNDANT_SEND_MAX;
}
else if (bXRPDirect && bMax)
{
// Consistent but redundant transaction.
m_journal.trace <<
"Malformed transaction: SendMax specified for XRP to XRP.";
return temBAD_SEND_XRP_MAX;
}
else if (bXRPDirect && bPaths)
//.........这里部分代码省略.........