mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Rework RPC ledger.
This commit is contained in:
@@ -861,9 +861,11 @@ Json::Value Ledger::getJson(int options)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ledger["closed"] = false;
|
||||
}
|
||||
|
||||
if (mTransactionMap && (bFull || ((options & LEDGER_JSON_DUMP_TXRP) != 0)))
|
||||
if (mTransactionMap && (bFull || isSetBit(options, LEDGER_JSON_DUMP_TXRP)))
|
||||
{
|
||||
Json::Value txns(Json::arrayValue);
|
||||
SHAMapTreeNode::TNType type;
|
||||
@@ -871,7 +873,7 @@ Json::Value Ledger::getJson(int options)
|
||||
for (SHAMapItem::pointer item = mTransactionMap->peekFirstItem(type); !!item;
|
||||
item = mTransactionMap->peekNextItem(item->getTag(), type))
|
||||
{
|
||||
if (bFull)
|
||||
if (bFull || isSetBit(options, LEDGER_JSON_EXPAND))
|
||||
{
|
||||
if (type == SHAMapTreeNode::tnTRANSACTION_NM)
|
||||
{
|
||||
@@ -904,14 +906,14 @@ Json::Value Ledger::getJson(int options)
|
||||
ledger["transactions"] = txns;
|
||||
}
|
||||
|
||||
if (mAccountStateMap && (bFull || ((options & LEDGER_JSON_DUMP_STATE) != 0)))
|
||||
if (mAccountStateMap && (bFull || isSetBit(options, LEDGER_JSON_DUMP_STATE)))
|
||||
{
|
||||
Json::Value state(Json::arrayValue);
|
||||
ScopedLock l(mAccountStateMap->Lock());
|
||||
for (SHAMapItem::pointer item = mAccountStateMap->peekFirstItem(); !!item;
|
||||
item = mAccountStateMap->peekNextItem(item->getTag()))
|
||||
{
|
||||
if (bFull)
|
||||
if (bFull || isSetBit(options, LEDGER_JSON_EXPAND))
|
||||
{
|
||||
SerializerIterator sit(item->peekSerializer());
|
||||
SerializedLedgerEntry sle(sit, item->getTag());
|
||||
|
||||
@@ -38,7 +38,8 @@ enum LedgerStateParms
|
||||
|
||||
#define LEDGER_JSON_DUMP_TXRP 0x10000000
|
||||
#define LEDGER_JSON_DUMP_STATE 0x20000000
|
||||
#define LEDGER_JSON_FULL 0x40000000
|
||||
#define LEDGER_JSON_EXPAND 0x40000000
|
||||
#define LEDGER_JSON_FULL 0x80000000
|
||||
|
||||
DEFINE_INSTANCE(Ledger);
|
||||
|
||||
|
||||
@@ -1636,12 +1636,19 @@ Json::Value RPCHandler::doLedger(Json::Value jvRequest, int& cost)
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
bool full = jvRequest.isMember("full") && jvRequest["full"].asBool();
|
||||
bool bFull = jvRequest.isMember("full") && jvRequest["full"].asBool();
|
||||
bool bTransactions = jvRequest.isMember("transactions") && jvRequest["transactions"].asBool();
|
||||
bool bAccounts = jvRequest.isMember("accounts") && jvRequest["accounts"].asBool();
|
||||
bool bExpand = jvRequest.isMember("expand") && jvRequest["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);
|
||||
|
||||
Json::Value ret(Json::objectValue);
|
||||
|
||||
ScopedUnlock(theApp->getMasterLock());
|
||||
lpLedger->addJson(ret, full ? LEDGER_JSON_FULL : 0);
|
||||
lpLedger->addJson(ret, iOptions);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user