本文整理汇总了C++中ledger::pointer::addJson方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::addJson方法的具体用法?C++ pointer::addJson怎么用?C++ pointer::addJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ledger::pointer
的用法示例。
在下文中一共展示了pointer::addJson方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doLedgerHeader
// {
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value doLedgerHeader (RPC::Context& context)
{
Ledger::pointer lpLedger;
Json::Value jvResult = RPC::lookupLedger (
context.params_, lpLedger, context.netOps_);
if (!lpLedger)
return jvResult;
Serializer s;
lpLedger->addRaw (s);
jvResult["ledger_data"] = strHex (s.peekData ());
// This information isn't verified: they should only use it if they trust
// us.
lpLedger->addJson (jvResult, 0);
return jvResult;
}
示例2: doLedger
// ledger [id|index|current|closed] [full]
// {
// ledger: 'current' | 'closed' | <uint256> | <number>, // optional
// full: true | false // optional, defaults to false.
// }
Json::Value doLedger (RPC::Context& context)
{
if (!context.params_.isMember ("ledger")
&& !context.params_.isMember ("ledger_hash")
&& !context.params_.isMember ("ledger_index"))
{
Json::Value ret (Json::objectValue), current (Json::objectValue),
closed (Json::objectValue);
getApp().getLedgerMaster ().getCurrentLedger ()->addJson (current, 0);
getApp().getLedgerMaster ().getClosedLedger ()->addJson (closed, 0);
ret["open"] = current;
ret["closed"] = closed;
return ret;
}
Ledger::pointer lpLedger;
Json::Value jvResult = RPC::lookupLedger (
context.params_, lpLedger, context.netOps_);
if (!lpLedger)
return jvResult;
bool bFull = context.params_.isMember ("full")
&& context.params_["full"].asBool ();
bool bTransactions = context.params_.isMember ("transactions")
&& context.params_["transactions"].asBool ();
bool bAccounts = context.params_.isMember ("accounts")
&& context.params_["accounts"].asBool ();
bool bExpand = context.params_.isMember ("expand")
&& context.params_["expand"].asBool ();
int iOptions = (bFull ? LEDGER_JSON_FULL : 0)
| (bExpand ? LEDGER_JSON_EXPAND : 0)
| (bTransactions ? LEDGER_JSON_DUMP_TXRP : 0)
| (bAccounts ? LEDGER_JSON_DUMP_STATE : 0);
if (bFull || bAccounts)
{
if (context.role_ != Config::ADMIN)
{
// Until some sane way to get full ledgers has been implemented,
// disallow retrieving all state nodes.
return rpcError (rpcNO_PERMISSION);
}
if (getApp().getFeeTrack().isLoadedLocal() &&
context.role_ != Config::ADMIN)
{
WriteLog (lsDEBUG, Peer) << "Too busy to give full ledger";
return rpcError(rpcTOO_BUSY);
}
context.loadType_ = Resource::feeHighBurdenRPC;
}
Json::Value ret (Json::objectValue);
lpLedger->addJson (ret, iOptions);
return ret;
}