本文整理汇总了C++中sle::pointer::getJson方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::getJson方法的具体用法?C++ pointer::getJson怎么用?C++ pointer::getJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sle::pointer
的用法示例。
在下文中一共展示了pointer::getJson方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyFee
TER Change::applyFee ()
{
SLE::pointer feeObject = mEngine->entryCache (
ltFEE_SETTINGS, Ledger::getLedgerFeeIndex ());
if (!feeObject)
feeObject = mEngine->entryCreate (
ltFEE_SETTINGS, Ledger::getLedgerFeeIndex ());
m_journal.trace <<
"Previous fee object: " << feeObject->getJson (0);
feeObject->setFieldU64 (
sfBaseFee, mTxn.getFieldU64 (sfBaseFee));
feeObject->setFieldU32 (
sfReferenceFeeUnits, mTxn.getFieldU32 (sfReferenceFeeUnits));
feeObject->setFieldU32 (
sfReserveBase, mTxn.getFieldU32 (sfReserveBase));
feeObject->setFieldU32 (
sfReserveIncrement, mTxn.getFieldU32 (sfReserveIncrement));
mEngine->entryModify (feeObject);
m_journal.trace <<
"New fee object: " << feeObject->getJson (0);
m_journal.warning << "Fees have been changed";
return tesSUCCESS;
}
示例2: bPassive
TER
CreateOffer::doApply ()
{
if (m_journal.debug) m_journal.debug <<
"OfferCreate> " << mTxn.getJson (0);
std::uint32_t const uTxFlags = mTxn.getFlags ();
bool const bPassive (uTxFlags & tfPassive);
bool const bImmediateOrCancel (uTxFlags & tfImmediateOrCancel);
bool const bFillOrKill (uTxFlags & tfFillOrKill);
bool const bSell (uTxFlags & tfSell);
STAmount saTakerPays = mTxn.getFieldAmount (sfTakerPays);
STAmount saTakerGets = mTxn.getFieldAmount (sfTakerGets);
if (!saTakerPays.isLegalNet () || !saTakerGets.isLegalNet ())
return temBAD_AMOUNT;
auto const& uPaysIssuerID = saTakerPays.getIssuer ();
auto const& uPaysCurrency = saTakerPays.getCurrency ();
auto const& uGetsIssuerID = saTakerGets.getIssuer ();
auto const& uGetsCurrency = saTakerGets.getCurrency ();
bool const bHaveExpiration (mTxn.isFieldPresent (sfExpiration));
bool const bHaveCancel (mTxn.isFieldPresent (sfOfferSequence));
std::uint32_t const uExpiration = mTxn.getFieldU32 (sfExpiration);
std::uint32_t const uCancelSequence = mTxn.getFieldU32 (sfOfferSequence);
// FIXME understand why we use SequenceNext instead of current transaction
// sequence to determine the transaction. Why is the offer seuqnce
// number insufficient?
std::uint32_t const uAccountSequenceNext = mTxnAccount->getFieldU32 (sfSequence);
std::uint32_t const uSequence = mTxn.getSequence ();
const uint256 uLedgerIndex = Ledger::getOfferIndex (mTxnAccountID, uSequence);
if (m_journal.debug)
{
m_journal.debug <<
"Creating offer node: " << to_string (uLedgerIndex) <<
" uSequence=" << uSequence;
if (bImmediateOrCancel)
m_journal.debug << "Transaction: IoC set.";
if (bFillOrKill)
m_journal.debug << "Transaction: FoK set.";
}
// This is the original rate of this offer, and is the rate at which it will
// be placed, even if crossing offers change the amounts.
std::uint64_t const uRate = STAmount::getRate (saTakerGets, saTakerPays);
TER terResult (tesSUCCESS);
// This is the ledger view that we work against. Transactions are applied
// as we go on processing transactions.
core::LedgerView& view (mEngine->view ());
// This is a checkpoint with just the fees paid. If something goes wrong
// with this transaction, we roll back to this ledger.
core::LedgerView view_checkpoint (view);
view.bumpSeq (); // Begin ledger variance.
SLE::pointer sleCreator = mEngine->entryCache (
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (mTxnAccountID));
if (uTxFlags & tfOfferCreateMask)
{
if (m_journal.debug) m_journal.debug <<
"Malformed transaction: Invalid flags set.";
terResult = temINVALID_FLAG;
}
else if (bImmediateOrCancel && bFillOrKill)
{
if (m_journal.debug) m_journal.debug <<
"Malformed transaction: both IoC and FoK set.";
terResult = temINVALID_FLAG;
}
else if (bHaveExpiration && !uExpiration)
{
m_journal.warning <<
"Malformed offer: bad expiration";
terResult = temBAD_EXPIRATION;
}
else if (saTakerPays.isNative () && saTakerGets.isNative ())
{
m_journal.warning <<
"Malformed offer: XRP for XRP";
terResult = temBAD_OFFER;
}
//.........这里部分代码省略.........
示例3: takeOffers
//.........这里部分代码省略.........
% uTakeQuality
% (uTakeQuality == uTipQuality
? '='
: uTakeQuality < uTipQuality
? '<'
: '>')
% uTipQuality
% saTakerRate
% (saTakerRate == saTipRate
? '='
: saTakerRate < saTipRate
? '<'
: '>')
% saTipRate
% bPassive);
terResult = tesSUCCESS;
}
else
{
// We have a crossing offer to consider.
SLE::pointer sleOffer = bookIterator.getCurrentOffer ();
if (!sleOffer)
{ // offer is in directory but not in ledger
uint256 offerIndex = bookIterator.getCurrentIndex ();
WriteLog (lsWARNING, OfferCreateTransactor) << "takeOffers: offer not found : " << offerIndex;
usMissingOffers.insert (missingOffer_t (
bookIterator.getCurrentIndex (), bookIterator.getCurrentDirectory ()));
}
else
{
WriteLog (lsDEBUG, OfferCreateTransactor) << "takeOffers: considering offer : " << sleOffer->getJson (0);
const uint160& uOfferOwnerID = sleOffer->getFieldAccount160 (sfAccount);
STAmount saOfferPays = sleOffer->getFieldAmount (sfTakerGets);
STAmount saOfferGets = sleOffer->getFieldAmount (sfTakerPays);
STAmount saOfferFunds; // Funds of offer owner to payout.
bool bValid;
bValid = bValidOffer (
sleOffer, uOfferOwnerID, saOfferPays, saOfferGets,
uTakerAccountID,
usOfferUnfundedFound, usOfferUnfundedBecame, usAccountTouched,
saOfferFunds);
if (bValid)
{
STAmount saSubTakerPaid;
STAmount saSubTakerGot;
STAmount saTakerIssuerFee;
STAmount saOfferIssuerFee;
STAmount saOfferRate = STAmount::setRate (uTipQuality);
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saTakerPays: " << saTakerPays.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saTakerPaid: " << saTakerPaid.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saTakerFunds: " << saTakerFunds.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saOfferFunds: " << saOfferFunds.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saOfferPays: " << saOfferPays.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saOfferGets: " << saOfferGets.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saOfferRate: " << saOfferRate.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saSubTakerPays: " << saSubTakerPays.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saSubTakerGets: " << saSubTakerGets.getFullText ();
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: applyOffer: saTakerPays: " << saTakerPays.getFullText ();
示例4: takeOffers
//.........这里部分代码省略.........
bUnfunded = true; // Don't create an order.
terResult = tesSUCCESS;
}
else if (!sleOfferDir // No offer directory to take.
|| uTakeQuality < uTipQuality // No offers of sufficient quality available.
|| (bPassive && uTakeQuality == uTipQuality))
{
// Done.
STAmount saTipRate = sleOfferDir ? STAmount::setRate (uTipQuality) : saTakerRate;
WriteLog (lsDEBUG, OfferCreateTransactor) << boost::str (boost::format ("takeOffers: done: dir=%d uTakeQuality=%d %c uTipQuality=%d saTakerRate=%s %c saTipRate=%s bPassive=%d")
% !!sleOfferDir
% uTakeQuality
% (uTakeQuality == uTipQuality
? '='
: uTakeQuality < uTipQuality
? '<'
: '>')
% uTipQuality
% saTakerRate
% (saTakerRate == saTipRate
? '='
: saTakerRate < saTipRate
? '<'
: '>')
% saTipRate
% bPassive);
terResult = tesSUCCESS;
}
else
{
// Have an offer directory to consider.
WriteLog (lsTRACE, OfferCreateTransactor) << "takeOffers: considering dir: " << sleOfferDir->getJson (0);
SLE::pointer sleBookNode;
unsigned int uBookEntry;
uint256 uOfferIndex;
lesActive.dirFirst (uTipIndex, sleBookNode, uBookEntry, uOfferIndex);
SLE::pointer sleOffer = mEngine->entryCache (ltOFFER, uOfferIndex);
WriteLog (lsDEBUG, OfferCreateTransactor) << "takeOffers: considering offer : " << sleOffer->getJson (0);
const uint160 uOfferOwnerID = sleOffer->getFieldAccount160 (sfAccount);
STAmount saOfferPays = sleOffer->getFieldAmount (sfTakerGets);
STAmount saOfferGets = sleOffer->getFieldAmount (sfTakerPays);
STAmount saOfferFunds; // Funds of offer owner to payout.
bool bValid;
bValid = bValidOffer (
sleOfferDir, uOfferIndex, uOfferOwnerID, saOfferPays, saOfferGets,
uTakerAccountID,
usOfferUnfundedFound, usOfferUnfundedBecame, usAccountTouched,
saOfferFunds);
if (bValid)
{
STAmount saSubTakerPaid;
STAmount saSubTakerGot;
STAmount saTakerIssuerFee;
STAmount saOfferIssuerFee;
STAmount saOfferRate = STAmount::setRate (uTipQuality);
示例5: doLedgerEntry
//.........这里部分代码省略.........
na0Public.setAccountPublic (naGenerator, 0);
uNodeIndex = Ledger::getGeneratorIndex (na0Public.getAccountID ());
}
}
else if (params.isMember ("offer"))
{
RippleAddress naAccountID;
if (!params["offer"].isObject ())
{
uNodeIndex.SetHex (params["offer"].asString ());
}
else if (!params["offer"].isMember ("account")
|| !params["offer"].isMember ("seq")
|| !params["offer"]["seq"].isIntegral ())
{
jvResult["error"] = "malformedRequest";
}
else if (!naAccountID.setAccountID (params["offer"]["account"].asString ()))
{
jvResult["error"] = "malformedAddress";
}
else
{
std::uint32_t uSequence = params["offer"]["seq"].asUInt ();
uNodeIndex = Ledger::getOfferIndex (naAccountID.getAccountID (), uSequence);
}
}
else if (params.isMember ("ripple_state"))
{
RippleAddress naA;
RippleAddress naB;
uint160 uCurrency;
Json::Value jvRippleState = params["ripple_state"];
if (!jvRippleState.isObject ()
|| !jvRippleState.isMember ("currency")
|| !jvRippleState.isMember ("accounts")
|| !jvRippleState["accounts"].isArray ()
|| 2 != jvRippleState["accounts"].size ()
|| !jvRippleState["accounts"][0u].isString ()
|| !jvRippleState["accounts"][1u].isString ()
|| jvRippleState["accounts"][0u].asString () == jvRippleState["accounts"][1u].asString ()
)
{
jvResult["error"] = "malformedRequest";
}
else if (!naA.setAccountID (jvRippleState["accounts"][0u].asString ())
|| !naB.setAccountID (jvRippleState["accounts"][1u].asString ()))
{
jvResult["error"] = "malformedAddress";
}
else if (!STAmount::currencyFromString (uCurrency, jvRippleState["currency"].asString ()))
{
jvResult["error"] = "malformedCurrency";
}
else
{
uNodeIndex = Ledger::getRippleStateIndex (naA, naB, uCurrency);
}
}
else
{
jvResult["error"] = "unknownOption";
}
if (uNodeIndex.isNonZero ())
{
SLE::pointer sleNode = mNetOps->getSLEi (lpLedger, uNodeIndex);
if (params.isMember("binary"))
bNodeBinary = params["binary"].asBool();
if (!sleNode)
{
// Not found.
// XXX Should also provide proof.
jvResult["error"] = "entryNotFound";
}
else if (bNodeBinary)
{
// XXX Should also provide proof.
Serializer s;
sleNode->add (s);
jvResult["node_binary"] = strHex (s.peekData ());
jvResult["index"] = uNodeIndex.ToString ();
}
else
{
jvResult["node"] = sleNode->getJson (0);
jvResult["index"] = uNodeIndex.ToString ();
}
}
return jvResult;
}