mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 19:45:53 +00:00
Make RPC ledger_header work.
This commit is contained in:
@@ -229,6 +229,25 @@ Json::Value RPCParser::parseLedger(const Json::Value& jvParams)
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
// ledger_header <id>|<index>
|
||||
Json::Value RPCParser::parseLedgerId(const Json::Value& jvParams)
|
||||
{
|
||||
Json::Value jvRequest(Json::objectValue);
|
||||
|
||||
std::string strLedger = jvParams[0u].asString();
|
||||
|
||||
if (strLedger.length() > 32)
|
||||
{
|
||||
jvRequest["ledger_hash"] = strLedger;
|
||||
}
|
||||
else
|
||||
{
|
||||
jvRequest["ledger_index"] = lexical_cast_s<uint32>(strLedger);
|
||||
}
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
#if ENABLE_INSECURE
|
||||
// login <username> <password>
|
||||
Json::Value RPCParser::parseLogin(const Json::Value& jvParams)
|
||||
@@ -484,7 +503,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
||||
{ "ledger_closed", &RPCParser::parseAsIs, 0, 0 },
|
||||
{ "ledger_current", &RPCParser::parseAsIs, 0, 0 },
|
||||
// { "ledger_entry", &RPCParser::parseLedgerEntry, -1, -1 },
|
||||
// { "ledger_header", &RPCParser::parseLedgerHeader, -1, -1 },
|
||||
{ "ledger_header", &RPCParser::parseLedgerId, 1, 1 },
|
||||
{ "log_level", &RPCParser::parseLogLevel, 0, 2 },
|
||||
{ "logrotate", &RPCParser::parseAsIs, 0, 0 },
|
||||
// { "nickname_info", &RPCParser::parseNicknameInfo, 1, 1 },
|
||||
|
||||
@@ -23,6 +23,7 @@ protected:
|
||||
Json::Value parseEvented(const Json::Value& jvParams);
|
||||
Json::Value parseGetCounts(const Json::Value& jvParams);
|
||||
Json::Value parseLedger(const Json::Value& jvParams);
|
||||
Json::Value parseLedgerId(const Json::Value& jvParams);
|
||||
Json::Value parseInternal(const Json::Value& jvParams);
|
||||
#if ENABLE_INSECURE
|
||||
Json::Value parseLogin(const Json::Value& jvParams);
|
||||
|
||||
@@ -663,14 +663,14 @@ Json::Value Ledger::getJson(int options)
|
||||
{
|
||||
Json::Value ledger(Json::objectValue);
|
||||
|
||||
bool full = (options & LEDGER_JSON_FULL) != 0;
|
||||
bool bFull = isSetBit(options, LEDGER_JSON_FULL);
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
|
||||
ledger["parentHash"] = mParentHash.GetHex();
|
||||
ledger["seqNum"] = boost::lexical_cast<std::string>(mLedgerSeq);
|
||||
|
||||
if(mClosed || full)
|
||||
if (mClosed || bFull)
|
||||
{
|
||||
if (mClosed)
|
||||
ledger["closed"] = true;
|
||||
@@ -693,14 +693,14 @@ Json::Value Ledger::getJson(int options)
|
||||
else
|
||||
ledger["closed"] = false;
|
||||
|
||||
if (mTransactionMap && (full || ((options & LEDGER_JSON_DUMP_TXRP) != 0)))
|
||||
if (mTransactionMap && (bFull || ((options & LEDGER_JSON_DUMP_TXRP) != 0)))
|
||||
{
|
||||
Json::Value txns(Json::arrayValue);
|
||||
SHAMapTreeNode::TNType type;
|
||||
for (SHAMapItem::pointer item = mTransactionMap->peekFirstItem(type); !!item;
|
||||
item = mTransactionMap->peekNextItem(item->getTag(), type))
|
||||
{
|
||||
if (full)
|
||||
if (bFull)
|
||||
{
|
||||
if (type == SHAMapTreeNode::tnTRANSACTION_NM)
|
||||
{
|
||||
@@ -733,13 +733,13 @@ Json::Value Ledger::getJson(int options)
|
||||
ledger["transactions"] = txns;
|
||||
}
|
||||
|
||||
if (mAccountStateMap && (full || ((options & LEDGER_JSON_DUMP_STATE) != 0)))
|
||||
if (mAccountStateMap && (bFull || ((options & LEDGER_JSON_DUMP_STATE) != 0)))
|
||||
{
|
||||
Json::Value state(Json::arrayValue);
|
||||
for (SHAMapItem::pointer item = mAccountStateMap->peekFirstItem(); !!item;
|
||||
item = mAccountStateMap->peekNextItem(item->getTag()))
|
||||
{
|
||||
if (full)
|
||||
if (bFull)
|
||||
{
|
||||
SerializerIterator sit(item->peekSerializer());
|
||||
SerializedLedgerEntry sle(sit, item->getTag());
|
||||
|
||||
@@ -2076,6 +2076,7 @@ Json::Value RPCHandler::lookupLedger(Json::Value jvRequest, Ledger::pointer& lpL
|
||||
// {
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// ...
|
||||
// }
|
||||
Json::Value RPCHandler::doLedgerEntry(Json::Value jvRequest)
|
||||
{
|
||||
@@ -2299,9 +2300,13 @@ Json::Value RPCHandler::doLedgerHeader(Json::Value jvRequest)
|
||||
jvResult["ledger_data"] = strHex(s.peekData());
|
||||
|
||||
if (mRole == ADMIN)
|
||||
{
|
||||
// As admin, they can trust us, so we provide this information.
|
||||
lpLedger->setClosed(); // XXX Hack to get info.
|
||||
lpLedger->addJson(jvResult, 0);
|
||||
}
|
||||
|
||||
return jvRequest;
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
boost::unordered_set<RippleAddress> RPCHandler::parseAccountIds(const Json::Value& jvArray)
|
||||
|
||||
Reference in New Issue
Block a user