mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Use Json::StaticString to improve performance:
* Move JSON-RPC fields to jsonrpc_fields.h
This commit is contained in:
committed by
Vinnie Falco
parent
34cbb26e47
commit
6fcf3fedb6
File diff suppressed because it is too large
Load Diff
@@ -3348,6 +3348,9 @@
|
||||
<ClInclude Include="..\..\src\ripple\proto\ripple.pb.h">
|
||||
<Filter>[1] Ripple\proto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\common\jsonrpc_fields.h">
|
||||
<Filter>[1] Ripple\common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\doc\CheatSheet.md">
|
||||
|
||||
@@ -23,12 +23,11 @@ Global
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Release|Win32.Build.0 = Release|Win32
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Release|x64.ActiveCfg = Release|x64
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Release|x64.Build.0 = Release|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|Win32.ActiveCfg = Debug|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|Win32.Build.0 = Debug|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|x64.Build.0 = Debug|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Release|Win32.Build.0 = Release|Win32
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Release|Win32.ActiveCfg = Release|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Release|x64.ActiveCfg = Release|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
|
||||
172
src/ripple/common/jsonrpc_fields.h
Normal file
172
src/ripple/common/jsonrpc_fields.h
Normal file
@@ -0,0 +1,172 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_COMMON_JSONRPC_FIELDS_H_INCLUDED
|
||||
#define RIPPLE_COMMON_JSONRPC_FIELDS_H_INCLUDED
|
||||
|
||||
#include "../json/ripple_json.h"
|
||||
|
||||
namespace ripple {
|
||||
namespace jss {
|
||||
|
||||
// JSON static strings
|
||||
|
||||
#define JSS(x) const Json::StaticString x ( #x )
|
||||
|
||||
/* The "StaticString" field names are used instead of string literals to
|
||||
optimize the performance of accessing members of Json::Value objects.
|
||||
*/
|
||||
// VFALCO NOTE Some of these are part of the JSON-RPC API and some aren't
|
||||
// TODO Move the string not part of the JSON-RPC API into another file
|
||||
JSS ( accepted );
|
||||
JSS ( account );
|
||||
JSS ( account_hash );
|
||||
JSS ( account_index );
|
||||
JSS ( accountState );
|
||||
JSS ( accountTreeHash );
|
||||
JSS ( affected );
|
||||
JSS ( age );
|
||||
JSS ( amendment_blocked );
|
||||
JSS ( asks );
|
||||
JSS ( authorized );
|
||||
JSS ( balance );
|
||||
JSS ( base_fee );
|
||||
JSS ( base_fee_xrp );
|
||||
JSS ( bids );
|
||||
JSS ( binary );
|
||||
JSS ( build_version );
|
||||
JSS ( closed );
|
||||
JSS ( closed_ledger );
|
||||
JSS ( close_time );
|
||||
JSS ( close_time_estimated );
|
||||
JSS ( close_time_human );
|
||||
JSS ( close_time_resolution );
|
||||
JSS ( code );
|
||||
JSS ( command );
|
||||
JSS ( complete_ledgers );
|
||||
JSS ( consensus );
|
||||
JSS ( converge_time );
|
||||
JSS ( converge_time_s );
|
||||
JSS ( currency );
|
||||
JSS ( date );
|
||||
JSS ( engine_result );
|
||||
JSS ( engine_result_code );
|
||||
JSS ( engine_result_message );
|
||||
JSS ( error );
|
||||
JSS ( error_exception );
|
||||
JSS ( fee_base );
|
||||
JSS ( fee_ref );
|
||||
JSS ( fetch_pack );
|
||||
JSS ( flags );
|
||||
JSS ( hash );
|
||||
JSS ( hostid );
|
||||
JSS ( id );
|
||||
JSS ( issuer );
|
||||
JSS ( last_close );
|
||||
JSS ( ledger );
|
||||
JSS ( ledgerClosed );
|
||||
JSS ( ledger_current_index );
|
||||
JSS ( ledger_hash );
|
||||
JSS ( ledger_index );
|
||||
JSS ( ledger_index_max );
|
||||
JSS ( ledger_index_min );
|
||||
JSS ( ledger_time );
|
||||
JSS ( limit );
|
||||
JSS ( limit_peer );
|
||||
JSS ( lines );
|
||||
JSS ( load );
|
||||
JSS ( load_base );
|
||||
JSS ( load_factor );
|
||||
JSS ( load_factor_cluster );
|
||||
JSS ( load_factor_local );
|
||||
JSS ( load_factor_net );
|
||||
JSS ( load_fee );
|
||||
JSS ( marker );
|
||||
JSS ( message );
|
||||
JSS ( meta );
|
||||
JSS ( metaData );
|
||||
JSS ( method );
|
||||
JSS ( missingCommand );
|
||||
JSS ( name );
|
||||
JSS ( network_ledger );
|
||||
JSS ( none );
|
||||
JSS ( no_ripple );
|
||||
JSS ( no_ripple_peer );
|
||||
JSS ( offers );
|
||||
JSS ( params );
|
||||
JSS ( parent_hash );
|
||||
JSS ( peer );
|
||||
JSS ( peer_authorized );
|
||||
JSS ( peer_index );
|
||||
JSS ( peers );
|
||||
JSS ( proposed );
|
||||
JSS ( proposers );
|
||||
JSS ( pubkey_node );
|
||||
JSS ( pubkey_validator );
|
||||
JSS ( published_ledger );
|
||||
JSS ( quality );
|
||||
JSS ( quality_in );
|
||||
JSS ( quality_out );
|
||||
JSS ( random );
|
||||
JSS ( raw_meta );
|
||||
JSS ( request );
|
||||
JSS ( reserve_base );
|
||||
JSS ( reserve_base_xrp );
|
||||
JSS ( reserve_inc );
|
||||
JSS ( reserve_inc_xrp );
|
||||
JSS ( response );
|
||||
JSS ( result );
|
||||
JSS ( ripple_lines );
|
||||
JSS ( seq );
|
||||
JSS ( seqNum );
|
||||
JSS ( server_state );
|
||||
JSS ( server_status );
|
||||
JSS ( stand_alone );
|
||||
JSS ( status );
|
||||
JSS ( success );
|
||||
JSS ( taker_gets );
|
||||
JSS ( taker_gets_funded );
|
||||
JSS ( taker_pays );
|
||||
JSS ( taker_pays_funded );
|
||||
JSS ( total_coins );
|
||||
JSS ( totalCoins );
|
||||
JSS ( transaction );
|
||||
JSS ( transaction_hash );
|
||||
JSS ( transactions );
|
||||
JSS ( transTreeHash );
|
||||
JSS ( tx );
|
||||
JSS ( tx_blob );
|
||||
JSS ( tx_json );
|
||||
JSS ( txn_count );
|
||||
JSS ( type );
|
||||
JSS ( type_hex );
|
||||
JSS ( validated );
|
||||
JSS ( validated_ledger );
|
||||
JSS ( validated_ledgers );
|
||||
JSS ( validation_quorum );
|
||||
JSS ( value );
|
||||
JSS ( waiting );
|
||||
JSS ( warning );
|
||||
|
||||
#undef JSS
|
||||
|
||||
} // jss
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -54,19 +54,19 @@ std::string AcceptedLedgerTx::getEscMeta () const
|
||||
void AcceptedLedgerTx::buildJson ()
|
||||
{
|
||||
mJson = Json::objectValue;
|
||||
mJson["transaction"] = mTxn->getJson (0);
|
||||
mJson[jss::transaction] = mTxn->getJson (0);
|
||||
|
||||
if (mMeta)
|
||||
{
|
||||
mJson["meta"] = mMeta->getJson (0);
|
||||
mJson["raw_meta"] = strHex (mRawMeta);
|
||||
mJson[jss::meta] = mMeta->getJson (0);
|
||||
mJson[jss::raw_meta] = strHex (mRawMeta);
|
||||
}
|
||||
|
||||
mJson["result"] = transHuman (mResult);
|
||||
mJson[jss::result] = transHuman (mResult);
|
||||
|
||||
if (!mAffected.empty ())
|
||||
{
|
||||
Json::Value& affected = (mJson["affected"] = Json::arrayValue);
|
||||
Json::Value& affected = (mJson[jss::affected] = Json::arrayValue);
|
||||
BOOST_FOREACH (const RippleAddress & ra, mAffected)
|
||||
{
|
||||
affected.append (ra.humanAccountID ());
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../../ripple/common/jsonrpc_fields.h"
|
||||
|
||||
#include "../../beast/beast/unit_test/suite.h"
|
||||
|
||||
namespace ripple {
|
||||
@@ -1005,7 +1007,7 @@ Ledger::pointer Ledger::getLastFullLedger ()
|
||||
|
||||
void Ledger::addJson (Json::Value& ret, int options)
|
||||
{
|
||||
ret["ledger"] = getJson (options);
|
||||
ret[jss::ledger] = getJson (options);
|
||||
}
|
||||
|
||||
static void stateItemTagAppender(Json::Value& value, SHAMapItem::ref smi)
|
||||
@@ -1026,43 +1028,43 @@ Json::Value Ledger::getJson (int options)
|
||||
|
||||
ScopedLockType sl (mLock);
|
||||
|
||||
ledger["seqNum"] = beast::lexicalCastThrow <std::string> (mLedgerSeq); // DEPRECATED
|
||||
ledger[jss::seqNum] = beast::lexicalCastThrow <std::string> (mLedgerSeq); // DEPRECATED
|
||||
|
||||
ledger["parent_hash"] = mParentHash.GetHex ();
|
||||
ledger["ledger_index"] = beast::lexicalCastThrow <std::string> (mLedgerSeq);
|
||||
ledger[jss::parent_hash] = mParentHash.GetHex ();
|
||||
ledger[jss::ledger_index] = beast::lexicalCastThrow <std::string> (mLedgerSeq);
|
||||
|
||||
if (mClosed || bFull)
|
||||
{
|
||||
if (mClosed)
|
||||
ledger["closed"] = true;
|
||||
ledger[jss::closed] = true;
|
||||
|
||||
ledger["hash"] = mHash.GetHex (); // DEPRECATED
|
||||
ledger["totalCoins"] = beast::lexicalCastThrow <std::string> (mTotCoins); // DEPRECATED
|
||||
ledger[jss::hash] = mHash.GetHex (); // DEPRECATED
|
||||
ledger[jss::totalCoins] = beast::lexicalCastThrow <std::string> (mTotCoins); // DEPRECATED
|
||||
|
||||
ledger["ledger_hash"] = mHash.GetHex ();
|
||||
ledger["transaction_hash"] = mTransHash.GetHex ();
|
||||
ledger["account_hash"] = mAccountHash.GetHex ();
|
||||
ledger["accepted"] = mAccepted;
|
||||
ledger["total_coins"] = beast::lexicalCastThrow <std::string> (mTotCoins);
|
||||
ledger[jss::ledger_hash] = mHash.GetHex ();
|
||||
ledger[jss::transaction_hash] = mTransHash.GetHex ();
|
||||
ledger[jss::account_hash] = mAccountHash.GetHex ();
|
||||
ledger[jss::accepted] = mAccepted;
|
||||
ledger[jss::total_coins] = beast::lexicalCastThrow <std::string> (mTotCoins);
|
||||
|
||||
if (mCloseTime != 0)
|
||||
{
|
||||
ledger["close_time"] = mCloseTime;
|
||||
ledger["close_time_human"] = boost::posix_time::to_simple_string (ptFromSeconds (mCloseTime));
|
||||
ledger["close_time_resolution"] = mCloseResolution;
|
||||
ledger[jss::close_time] = mCloseTime;
|
||||
ledger[jss::close_time_human] = boost::posix_time::to_simple_string (ptFromSeconds (mCloseTime));
|
||||
ledger[jss::close_time_resolution] = mCloseResolution;
|
||||
|
||||
if ((mCloseFlags & sLCF_NoConsensusTime) != 0)
|
||||
ledger["close_time_estimated"] = true;
|
||||
ledger[jss::close_time_estimated] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ledger["closed"] = false;
|
||||
ledger[jss::closed] = false;
|
||||
}
|
||||
|
||||
if (mTransactionMap && (bFull || is_bit_set (options, LEDGER_JSON_DUMP_TXRP)))
|
||||
{
|
||||
Json::Value txns (Json::arrayValue);
|
||||
Json::Value& txns = (ledger[jss::transactions] = Json::arrayValue);
|
||||
SHAMapTreeNode::TNType type;
|
||||
|
||||
for (SHAMapItem::pointer item = mTransactionMap->peekFirstItem (type); !!item;
|
||||
@@ -1086,7 +1088,7 @@ Json::Value Ledger::getJson (int options)
|
||||
|
||||
TransactionMetaSet meta (item->getTag (), mLedgerSeq, sit.getVL ());
|
||||
Json::Value txJson = txn.getJson (0);
|
||||
txJson["metaData"] = meta.getJson (0);
|
||||
txJson[jss::metaData] = meta.getJson (0);
|
||||
txns.append (txJson);
|
||||
}
|
||||
else
|
||||
@@ -1099,12 +1101,11 @@ Json::Value Ledger::getJson (int options)
|
||||
else txns.append (item->getTag ().GetHex ());
|
||||
}
|
||||
|
||||
ledger["transactions"] = txns;
|
||||
}
|
||||
|
||||
if (mAccountStateMap && (bFull || is_bit_set (options, LEDGER_JSON_DUMP_STATE)))
|
||||
{
|
||||
Json::Value& state = (ledger["accountState"] = Json::arrayValue);
|
||||
Json::Value& state = (ledger[jss::accountState] = Json::arrayValue);
|
||||
if (bFull || is_bit_set (options, LEDGER_JSON_EXPAND))
|
||||
visitStateItems(BIND_TYPE(stateItemFullAppender, std::ref(state), P_1));
|
||||
else
|
||||
@@ -1809,8 +1810,8 @@ bool Ledger::assertSane ()
|
||||
|
||||
Json::Value j = getJson (0);
|
||||
|
||||
j ["accountTreeHash"] = mAccountHash.GetHex ();
|
||||
j ["transTreeHash"] = mTransHash.GetHex ();
|
||||
j [jss::accountTreeHash] = mAccountHash.GetHex ();
|
||||
j [jss::transTreeHash] = mTransHash.GetHex ();
|
||||
|
||||
assert (false);
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../../ripple/common/jsonrpc_fields.h"
|
||||
|
||||
namespace ripple {
|
||||
|
||||
bool ParameterNode::setValue (const std::string& name, const Json::Value& value, Json::Value& error)
|
||||
@@ -33,8 +35,8 @@ bool ParameterNode::setValue (const std::string& name, const Json::Value& value,
|
||||
if (it == mChildren.end ())
|
||||
{
|
||||
error = Json::objectValue;
|
||||
error["error"] = "Name not found";
|
||||
error["name"] = name;
|
||||
error[jss::error] = "Name not found";
|
||||
error[jss::name] = name;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ bool ParameterNode::setValue (const std::string& name, const Json::Value& value,
|
||||
if (it == mChildren.end ())
|
||||
{
|
||||
error = Json::objectValue;
|
||||
error["error"] = "Name not found";
|
||||
error["name"] = name;
|
||||
error[jss::error] = "Name not found";
|
||||
error[jss::name] = name;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -56,8 +58,8 @@ bool ParameterNode::setValue (const std::string& name, const Json::Value& value,
|
||||
if (!n)
|
||||
{
|
||||
error = Json::objectValue;
|
||||
error["error"] = "Node has no children";
|
||||
error["name"] = it->second->getName ();
|
||||
error[jss::error] = "Node has no children";
|
||||
error[jss::name] = it->second->getName ();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -119,7 +121,7 @@ Json::Value ParameterNode::getValue (int i) const
|
||||
bool ParameterNode::setValue (const Json::Value& value, Json::Value& error)
|
||||
{
|
||||
error = Json::objectValue;
|
||||
error["error"] = "Cannot end on an inner node";
|
||||
error[jss::error] = "Cannot end on an inner node";
|
||||
|
||||
Json::Value nodes (Json::arrayValue);
|
||||
typedef std::map<std::string, Parameter::pointer>::value_type string_ref_pair;
|
||||
@@ -147,8 +149,8 @@ bool ParameterString::setValue (const Json::Value& value, Json::Value& error)
|
||||
if (!value.isConvertibleTo (Json::stringValue))
|
||||
{
|
||||
error = Json::objectValue;
|
||||
error["error"] = "Cannot convert to string";
|
||||
error["value"] = value;
|
||||
error[jss::error] = "Cannot convert to string";
|
||||
error[jss::value] = value;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,8 +189,8 @@ bool ParameterInt::setValue (const Json::Value& value, Json::Value& error)
|
||||
}
|
||||
|
||||
error = Json::objectValue;
|
||||
error["error"] = "Cannot convert to integer";
|
||||
error["value"] = value;
|
||||
error[jss::error] = "Cannot convert to integer";
|
||||
error[jss::value] = value;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include "../../ripple_overlay/api/predicates.h"
|
||||
#include "../../ripple/common/jsonrpc_fields.h"
|
||||
|
||||
#include "../../beast/modules/beast_core/thread/DeadlineTimer.h"
|
||||
#include "../../beast/modules/beast_core/system/SystemStats.h"
|
||||
@@ -1150,17 +1151,17 @@ Json::Value NetworkOPsImp::getOwnerInfo (Ledger::pointer lpLedger, const RippleA
|
||||
switch (sleCur->getType ())
|
||||
{
|
||||
case ltOFFER:
|
||||
if (!jvObjects.isMember ("offers"))
|
||||
jvObjects["offers"] = Json::Value (Json::arrayValue);
|
||||
if (!jvObjects.isMember (jss::offers))
|
||||
jvObjects[jss::offers] = Json::Value (Json::arrayValue);
|
||||
|
||||
jvObjects["offers"].append (sleCur->getJson (0));
|
||||
jvObjects[jss::offers].append (sleCur->getJson (0));
|
||||
break;
|
||||
|
||||
case ltRIPPLE_STATE:
|
||||
if (!jvObjects.isMember ("ripple_lines"))
|
||||
jvObjects["ripple_lines"] = Json::Value (Json::arrayValue);
|
||||
if (!jvObjects.isMember (jss::ripple_lines))
|
||||
jvObjects[jss::ripple_lines] = Json::Value (Json::arrayValue);
|
||||
|
||||
jvObjects["ripple_lines"].append (sleCur->getJson (0));
|
||||
jvObjects[jss::ripple_lines].append (sleCur->getJson (0));
|
||||
break;
|
||||
|
||||
case ltACCOUNT_ROOT:
|
||||
@@ -1684,10 +1685,10 @@ void NetworkOPsImp::pubServer ()
|
||||
{
|
||||
Json::Value jvObj (Json::objectValue);
|
||||
|
||||
jvObj ["type"] = "serverStatus";
|
||||
jvObj ["server_status"] = strOperatingMode ();
|
||||
jvObj ["load_base"] = (mLastLoadBase = getApp().getFeeTrack ().getLoadBase ());
|
||||
jvObj ["load_factor"] = (mLastLoadFactor = getApp().getFeeTrack ().getLoadFactor ());
|
||||
jvObj [jss::type] = "serverStatus";
|
||||
jvObj [jss::server_status] = strOperatingMode ();
|
||||
jvObj [jss::load_base] = (mLastLoadBase = getApp().getFeeTrack ().getLoadBase ());
|
||||
jvObj [jss::load_factor] = (mLastLoadFactor = getApp().getFeeTrack ().getLoadFactor ());
|
||||
|
||||
Json::FastWriter w;
|
||||
std::string sObj = w.write (jvObj);
|
||||
@@ -1936,10 +1937,10 @@ NetworkOPsImp::getTxsAccount (const RippleAddress& account, std::int32_t minLedg
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!token.isMember("ledger") || !token.isMember("seq"))
|
||||
if (!token.isMember(jss::ledger) || !token.isMember(jss::seq))
|
||||
return ret;
|
||||
findLedger = token["ledger"].asInt();
|
||||
findSeq = token["seq"].asInt();
|
||||
findLedger = token[jss::ledger].asInt();
|
||||
findSeq = token[jss::seq].asInt();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -1978,8 +1979,8 @@ NetworkOPsImp::getTxsAccount (const RippleAddress& account, std::int32_t minLedg
|
||||
else if (numberOfResults == 0)
|
||||
{
|
||||
token = Json::objectValue;
|
||||
token["ledger"] = db->getInt("LedgerSeq");
|
||||
token["seq"] = db->getInt("TxnSeq");
|
||||
token[jss::ledger] = db->getInt("LedgerSeq");
|
||||
token[jss::seq] = db->getInt("TxnSeq");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2046,10 +2047,10 @@ NetworkOPsImp::getTxsAccountB (const RippleAddress& account, std::int32_t minLed
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!token.isMember("ledger") || !token.isMember("seq"))
|
||||
if (!token.isMember(jss::ledger) || !token.isMember(jss::seq))
|
||||
return ret;
|
||||
findLedger = token["ledger"].asInt();
|
||||
findSeq = token["seq"].asInt();
|
||||
findLedger = token[jss::ledger].asInt();
|
||||
findSeq = token[jss::seq].asInt();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -2086,8 +2087,8 @@ NetworkOPsImp::getTxsAccountB (const RippleAddress& account, std::int32_t minLed
|
||||
else if (numberOfResults == 0)
|
||||
{
|
||||
token = Json::objectValue;
|
||||
token["ledger"] = db->getInt("LedgerSeq");
|
||||
token["seq"] = db->getInt("TxnSeq");
|
||||
token[jss::ledger] = db->getInt("LedgerSeq");
|
||||
token[jss::seq] = db->getInt("TxnSeq");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2160,7 +2161,7 @@ Json::Value NetworkOPsImp::getConsensusInfo ()
|
||||
return mConsensus->getJson (true);
|
||||
|
||||
Json::Value info = Json::objectValue;
|
||||
info["consensus"] = "none";
|
||||
info[jss::consensus] = "none";
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -2176,86 +2177,86 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
|
||||
{
|
||||
// For a non admin connection, hash the node ID into a single RFC1751 word
|
||||
Blob const& addr (getApp().getLocalCredentials ().getNodePublic ().getNodePublic ());
|
||||
info ["hostid"] = RFC1751::getWordFromBlob (addr.data (), addr.size ());
|
||||
info [jss::hostid] = RFC1751::getWordFromBlob (addr.data (), addr.size ());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only admins get the hostname for security reasons
|
||||
info ["hostid"] = beast::SystemStats::getComputerName();
|
||||
info [jss::hostid] = beast::SystemStats::getComputerName();
|
||||
}
|
||||
}
|
||||
|
||||
info ["build_version"] = BuildInfo::getVersionString ();
|
||||
info [jss::build_version] = BuildInfo::getVersionString ();
|
||||
|
||||
info["server_state"] = strOperatingMode ();
|
||||
info [jss::server_state] = strOperatingMode ();
|
||||
|
||||
if (mNeedNetworkLedger)
|
||||
info["network_ledger"] = "waiting";
|
||||
info[jss::network_ledger] = jss::waiting;
|
||||
|
||||
info["validation_quorum"] = m_ledgerMaster.getMinValidations ();
|
||||
info[jss::validation_quorum] = m_ledgerMaster.getMinValidations ();
|
||||
|
||||
if (admin)
|
||||
{
|
||||
if (getConfig ().VALIDATION_PUB.isValid ())
|
||||
info["pubkey_validator"] = getConfig ().VALIDATION_PUB.humanNodePublic ();
|
||||
info[jss::pubkey_validator] = getConfig ().VALIDATION_PUB.humanNodePublic ();
|
||||
else
|
||||
info["pubkey_validator"] = "none";
|
||||
info[jss::pubkey_validator] = jss::none;
|
||||
}
|
||||
|
||||
info["pubkey_node"] = getApp().getLocalCredentials ().getNodePublic ().humanNodePublic ();
|
||||
info[jss::pubkey_node] = getApp().getLocalCredentials ().getNodePublic ().humanNodePublic ();
|
||||
|
||||
|
||||
info["complete_ledgers"] = getApp().getLedgerMaster ().getCompleteLedgers ();
|
||||
info[jss::complete_ledgers] = getApp().getLedgerMaster ().getCompleteLedgers ();
|
||||
|
||||
if (m_amendmentBlocked)
|
||||
info["amendment_blocked"] = true;
|
||||
info[jss::amendment_blocked] = true;
|
||||
|
||||
size_t fp = mFetchPack.getCacheSize ();
|
||||
|
||||
if (fp != 0)
|
||||
info["fetch_pack"] = Json::UInt (fp);
|
||||
info[jss::fetch_pack] = Json::UInt (fp);
|
||||
|
||||
info["peers"] = Json::UInt (getApp ().overlay ().size ());
|
||||
info[jss::peers] = Json::UInt (getApp ().overlay ().size ());
|
||||
|
||||
Json::Value lastClose = Json::objectValue;
|
||||
lastClose["proposers"] = getApp().getOPs ().getPreviousProposers ();
|
||||
lastClose[jss::proposers] = getApp().getOPs ().getPreviousProposers ();
|
||||
|
||||
if (human)
|
||||
lastClose["converge_time_s"] = static_cast<double> (getApp().getOPs ().getPreviousConvergeTime ()) / 1000.0;
|
||||
lastClose[jss::converge_time_s] = static_cast<double> (getApp().getOPs ().getPreviousConvergeTime ()) / 1000.0;
|
||||
else
|
||||
lastClose["converge_time"] = Json::Int (getApp().getOPs ().getPreviousConvergeTime ());
|
||||
lastClose[jss::converge_time] = Json::Int (getApp().getOPs ().getPreviousConvergeTime ());
|
||||
|
||||
info["last_close"] = lastClose;
|
||||
info[jss::last_close] = lastClose;
|
||||
|
||||
// if (mConsensus)
|
||||
// info["consensus"] = mConsensus->getJson();
|
||||
// info[jss::consensus] = mConsensus->getJson();
|
||||
|
||||
if (admin)
|
||||
info["load"] = getApp().getJobQueue ().getJson ();
|
||||
info[jss::load] = getApp().getJobQueue ().getJson ();
|
||||
|
||||
if (!human)
|
||||
{
|
||||
info["load_base"] = getApp().getFeeTrack ().getLoadBase ();
|
||||
info["load_factor"] = getApp().getFeeTrack ().getLoadFactor ();
|
||||
info[jss::load_base] = getApp().getFeeTrack ().getLoadBase ();
|
||||
info[jss::load_factor] = getApp().getFeeTrack ().getLoadFactor ();
|
||||
}
|
||||
else
|
||||
{
|
||||
info["load_factor"] =
|
||||
info[jss::load_factor] =
|
||||
static_cast<double> (getApp().getFeeTrack ().getLoadFactor ()) / getApp().getFeeTrack ().getLoadBase ();
|
||||
if (admin)
|
||||
{
|
||||
std::uint32_t base = getApp().getFeeTrack().getLoadBase();
|
||||
std::uint32_t fee = getApp().getFeeTrack().getLocalFee();
|
||||
if (fee != base)
|
||||
info["load_factor_local"] =
|
||||
info[jss::load_factor_local] =
|
||||
static_cast<double> (fee) / base;
|
||||
fee = getApp().getFeeTrack ().getRemoteFee();
|
||||
if (fee != base)
|
||||
info["load_factor_net"] =
|
||||
info[jss::load_factor_net] =
|
||||
static_cast<double> (fee) / base;
|
||||
fee = getApp().getFeeTrack().getClusterFee();
|
||||
if (fee != base)
|
||||
info["load_factor_cluster"] =
|
||||
info[jss::load_factor_cluster] =
|
||||
static_cast<double> (fee) / base;
|
||||
}
|
||||
}
|
||||
@@ -2273,22 +2274,22 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
|
||||
std::uint64_t baseFee = lpClosed->getBaseFee ();
|
||||
std::uint64_t baseRef = lpClosed->getReferenceFeeUnits ();
|
||||
Json::Value l (Json::objectValue);
|
||||
l["seq"] = Json::UInt (lpClosed->getLedgerSeq ());
|
||||
l["hash"] = lpClosed->getHash ().GetHex ();
|
||||
l[jss::seq] = Json::UInt (lpClosed->getLedgerSeq ());
|
||||
l[jss::hash] = lpClosed->getHash ().GetHex ();
|
||||
|
||||
if (!human)
|
||||
{
|
||||
l["base_fee"] = Json::Value::UInt (baseFee);
|
||||
l["reserve_base"] = Json::Value::UInt (lpClosed->getReserve (0));
|
||||
l["reserve_inc"] = Json::Value::UInt (lpClosed->getReserveInc ());
|
||||
l["close_time"] = Json::Value::UInt (lpClosed->getCloseTimeNC ());
|
||||
l[jss::base_fee] = Json::Value::UInt (baseFee);
|
||||
l[jss::reserve_base] = Json::Value::UInt (lpClosed->getReserve (0));
|
||||
l[jss::reserve_inc] = Json::Value::UInt (lpClosed->getReserveInc ());
|
||||
l[jss::close_time] = Json::Value::UInt (lpClosed->getCloseTimeNC ());
|
||||
}
|
||||
else
|
||||
{
|
||||
l["base_fee_xrp"] = static_cast<double> (baseFee) / SYSTEM_CURRENCY_PARTS;
|
||||
l["reserve_base_xrp"] =
|
||||
l[jss::base_fee_xrp] = static_cast<double> (baseFee) / SYSTEM_CURRENCY_PARTS;
|
||||
l[jss::reserve_base_xrp] =
|
||||
static_cast<double> (Json::UInt (lpClosed->getReserve (0) * baseFee / baseRef)) / SYSTEM_CURRENCY_PARTS;
|
||||
l["reserve_inc_xrp"] =
|
||||
l[jss::reserve_inc_xrp] =
|
||||
static_cast<double> (Json::UInt (lpClosed->getReserveInc () * baseFee / baseRef)) / SYSTEM_CURRENCY_PARTS;
|
||||
|
||||
std::uint32_t closeTime = getCloseTimeNC ();
|
||||
@@ -2299,20 +2300,20 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
|
||||
std::uint32_t age = closeTime - lCloseTime;
|
||||
|
||||
if (age < 1000000)
|
||||
l["age"] = Json::UInt (age);
|
||||
l[jss::age] = Json::UInt (age);
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
info["validated_ledger"] = l;
|
||||
info[jss::validated_ledger] = l;
|
||||
else
|
||||
info["closed_ledger"] = l;
|
||||
info[jss::closed_ledger] = l;
|
||||
|
||||
Ledger::pointer lpPublished = getPublishedLedger ();
|
||||
if (!lpPublished)
|
||||
info["published_ledger"] = "none";
|
||||
info[jss::published_ledger] = jss::none;
|
||||
else if (lpPublished->getLedgerSeq() != lpClosed->getLedgerSeq())
|
||||
info["published_ledger"] = lpPublished->getLedgerSeq();
|
||||
info[jss::published_ledger] = lpPublished->getLedgerSeq();
|
||||
}
|
||||
|
||||
return info;
|
||||
@@ -2387,20 +2388,20 @@ void NetworkOPsImp::pubLedger (Ledger::ref accepted)
|
||||
{
|
||||
Json::Value jvObj (Json::objectValue);
|
||||
|
||||
jvObj["type"] = "ledgerClosed";
|
||||
jvObj["ledger_index"] = lpAccepted->getLedgerSeq ();
|
||||
jvObj["ledger_hash"] = lpAccepted->getHash ().ToString ();
|
||||
jvObj["ledger_time"] = Json::Value::UInt (lpAccepted->getCloseTimeNC ());
|
||||
jvObj[jss::type] = jss::ledgerClosed;
|
||||
jvObj[jss::ledger_index] = lpAccepted->getLedgerSeq ();
|
||||
jvObj[jss::ledger_hash] = lpAccepted->getHash ().ToString ();
|
||||
jvObj[jss::ledger_time] = Json::Value::UInt (lpAccepted->getCloseTimeNC ());
|
||||
|
||||
jvObj["fee_ref"] = Json::UInt (lpAccepted->getReferenceFeeUnits ());
|
||||
jvObj["fee_base"] = Json::UInt (lpAccepted->getBaseFee ());
|
||||
jvObj["reserve_base"] = Json::UInt (lpAccepted->getReserve (0));
|
||||
jvObj["reserve_inc"] = Json::UInt (lpAccepted->getReserveInc ());
|
||||
jvObj[jss::fee_ref] = Json::UInt (lpAccepted->getReferenceFeeUnits ());
|
||||
jvObj[jss::fee_base] = Json::UInt (lpAccepted->getBaseFee ());
|
||||
jvObj[jss::reserve_base] = Json::UInt (lpAccepted->getReserve (0));
|
||||
jvObj[jss::reserve_inc] = Json::UInt (lpAccepted->getReserveInc ());
|
||||
|
||||
jvObj["txn_count"] = Json::UInt (alpAccepted->getTxnCount ());
|
||||
jvObj[jss::txn_count] = Json::UInt (alpAccepted->getTxnCount ());
|
||||
|
||||
if (mMode >= omSYNCING)
|
||||
jvObj["validated_ledgers"] = getApp().getLedgerMaster ().getCompleteLedgers ();
|
||||
jvObj[jss::validated_ledgers] = getApp().getLedgerMaster ().getCompleteLedgers ();
|
||||
|
||||
NetworkOPsImp::SubMapType::const_iterator it = mSubLedger.begin ();
|
||||
|
||||
@@ -2446,29 +2447,29 @@ Json::Value NetworkOPsImp::transJson (const SerializedTransaction& stTxn, TER te
|
||||
|
||||
transResultInfo (terResult, sToken, sHuman);
|
||||
|
||||
jvObj["type"] = "transaction";
|
||||
jvObj["transaction"] = stTxn.getJson (0);
|
||||
jvObj[jss::type] = jss::transaction;
|
||||
jvObj[jss::transaction] = stTxn.getJson (0);
|
||||
|
||||
if (bValidated)
|
||||
{
|
||||
jvObj["ledger_index"] = lpCurrent->getLedgerSeq ();
|
||||
jvObj["ledger_hash"] = lpCurrent->getHash ().ToString ();
|
||||
jvObj["transaction"]["date"] = lpCurrent->getCloseTimeNC ();
|
||||
jvObj["validated"] = true;
|
||||
jvObj[jss::ledger_index] = lpCurrent->getLedgerSeq ();
|
||||
jvObj[jss::ledger_hash] = lpCurrent->getHash ().ToString ();
|
||||
jvObj[jss::transaction][jss::date] = lpCurrent->getCloseTimeNC ();
|
||||
jvObj[jss::validated] = true;
|
||||
|
||||
// WRITEME: Put the account next seq here
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jvObj["validated"] = false;
|
||||
jvObj["ledger_current_index"] = lpCurrent->getLedgerSeq ();
|
||||
jvObj[jss::validated] = false;
|
||||
jvObj[jss::ledger_current_index] = lpCurrent->getLedgerSeq ();
|
||||
}
|
||||
|
||||
jvObj["status"] = bValidated ? "closed" : "proposed";
|
||||
jvObj["engine_result"] = sToken;
|
||||
jvObj["engine_result_code"] = terResult;
|
||||
jvObj["engine_result_message"] = sHuman;
|
||||
jvObj[jss::status] = bValidated ? jss::closed : jss::proposed;
|
||||
jvObj[jss::engine_result] = sToken;
|
||||
jvObj[jss::engine_result_code] = terResult;
|
||||
jvObj[jss::engine_result_message] = sHuman;
|
||||
|
||||
return jvObj;
|
||||
}
|
||||
@@ -2476,7 +2477,7 @@ Json::Value NetworkOPsImp::transJson (const SerializedTransaction& stTxn, TER te
|
||||
void NetworkOPsImp::pubValidatedTransaction (Ledger::ref alAccepted, const AcceptedLedgerTx& alTx)
|
||||
{
|
||||
Json::Value jvObj = transJson (*alTx.getTxn (), alTx.getResult (), true, alAccepted);
|
||||
jvObj["meta"] = alTx.getMeta ()->getJson (0);
|
||||
jvObj[jss::meta] = alTx.getMeta ()->getJson (0);
|
||||
|
||||
Json::FastWriter w;
|
||||
std::string sObj = w.write (jvObj);
|
||||
@@ -2590,7 +2591,7 @@ void NetworkOPsImp::pubAccountTransaction (Ledger::ref lpCurrent, const Accepted
|
||||
*alTx.getTxn (), alTx.getResult (), bAccepted, lpCurrent);
|
||||
|
||||
if (alTx.isApplied ())
|
||||
jvObj["meta"] = alTx.getMeta ()->getJson (0);
|
||||
jvObj[jss::meta] = alTx.getMeta ()->getJson (0);
|
||||
|
||||
Json::FastWriter w;
|
||||
std::string sObj = w.write (jvObj);
|
||||
@@ -2749,18 +2750,18 @@ bool NetworkOPsImp::subLedger (InfoSub::ref isrListener, Json::Value& jvResult)
|
||||
|
||||
if (lpClosed)
|
||||
{
|
||||
jvResult["ledger_index"] = lpClosed->getLedgerSeq ();
|
||||
jvResult["ledger_hash"] = lpClosed->getHash ().ToString ();
|
||||
jvResult["ledger_time"] = Json::Value::UInt (lpClosed->getCloseTimeNC ());
|
||||
jvResult[jss::ledger_index] = lpClosed->getLedgerSeq ();
|
||||
jvResult[jss::ledger_hash] = lpClosed->getHash ().ToString ();
|
||||
jvResult[jss::ledger_time] = Json::Value::UInt (lpClosed->getCloseTimeNC ());
|
||||
|
||||
jvResult["fee_ref"] = Json::UInt (lpClosed->getReferenceFeeUnits ());
|
||||
jvResult["fee_base"] = Json::UInt (lpClosed->getBaseFee ());
|
||||
jvResult["reserve_base"] = Json::UInt (lpClosed->getReserve (0));
|
||||
jvResult["reserve_inc"] = Json::UInt (lpClosed->getReserveInc ());
|
||||
jvResult[jss::fee_ref] = Json::UInt (lpClosed->getReferenceFeeUnits ());
|
||||
jvResult[jss::fee_base] = Json::UInt (lpClosed->getBaseFee ());
|
||||
jvResult[jss::reserve_base] = Json::UInt (lpClosed->getReserve (0));
|
||||
jvResult[jss::reserve_inc] = Json::UInt (lpClosed->getReserveInc ());
|
||||
}
|
||||
|
||||
if ((mMode >= omSYNCING) && !isNeedNetworkLedger ())
|
||||
jvResult["validated_ledgers"] = getApp().getLedgerMaster ().getCompleteLedgers ();
|
||||
jvResult[jss::validated_ledgers] = getApp().getLedgerMaster ().getCompleteLedgers ();
|
||||
|
||||
ScopedLockType sl (mLock);
|
||||
return mSubLedger.emplace (isrListener->getSeq (), isrListener).second;
|
||||
@@ -2779,13 +2780,13 @@ bool NetworkOPsImp::subServer (InfoSub::ref isrListener, Json::Value& jvResult)
|
||||
uint256 uRandom;
|
||||
|
||||
if (getConfig ().RUN_STANDALONE)
|
||||
jvResult["stand_alone"] = getConfig ().RUN_STANDALONE;
|
||||
jvResult[jss::stand_alone] = getConfig ().RUN_STANDALONE;
|
||||
|
||||
RandomNumbers::getInstance ().fillBytes (uRandom.begin (), uRandom.size ());
|
||||
jvResult["random"] = uRandom.ToString ();
|
||||
jvResult["server_status"] = strOperatingMode ();
|
||||
jvResult["load_base"] = getApp().getFeeTrack ().getLoadBase ();
|
||||
jvResult["load_factor"] = getApp().getFeeTrack ().getLoadFactor ();
|
||||
jvResult[jss::random] = uRandom.ToString ();
|
||||
jvResult[jss::server_status] = strOperatingMode ();
|
||||
jvResult[jss::load_base] = getApp().getFeeTrack ().getLoadBase ();
|
||||
jvResult[jss::load_factor] = getApp().getFeeTrack ().getLoadFactor ();
|
||||
|
||||
ScopedLockType sl (mLock);
|
||||
return mSubServer.emplace (isrListener->getSeq (), isrListener).second;
|
||||
@@ -2854,7 +2855,7 @@ InfoSub::pointer NetworkOPsImp::addRpcSub (const std::string& strUrl, InfoSub::r
|
||||
// FIXME : support iLimit.
|
||||
void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTakerPaysCurrencyID, const uint160& uTakerPaysIssuerID, const uint160& uTakerGetsCurrencyID, const uint160& uTakerGetsIssuerID, const uint160& uTakerID, const bool bProof, const unsigned int iLimit, const Json::Value& jvMarker, Json::Value& jvResult)
|
||||
{ // CAUTION: This is the old get book page logic
|
||||
Json::Value& jvOffers = (jvResult["offers"] = Json::Value (Json::arrayValue));
|
||||
Json::Value& jvOffers = (jvResult[jss::offers] = Json::Value (Json::arrayValue));
|
||||
|
||||
std::map<uint160, STAmount> umBalance;
|
||||
const uint256 uBookBase = Ledger::getBookBase (uTakerPaysCurrencyID, uTakerPaysIssuerID, uTakerGetsCurrencyID, uTakerGetsIssuerID);
|
||||
@@ -3004,8 +3005,10 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker
|
||||
|
||||
saTakerGetsFunded = saOwnerFundsLimit;
|
||||
|
||||
saTakerGetsFunded.setJson (jvOffer["taker_gets_funded"]);
|
||||
std::min (saTakerPays, STAmount::multiply (saTakerGetsFunded, saDirRate, saTakerPays)).setJson (jvOffer["taker_pays_funded"]);
|
||||
saTakerGetsFunded.setJson (jvOffer[jss::taker_gets_funded]);
|
||||
std::min (saTakerPays,
|
||||
STAmount::multiply (saTakerGetsFunded, saDirRate, saTakerPays)).setJson
|
||||
(jvOffer[jss::taker_pays_funded]);
|
||||
}
|
||||
|
||||
STAmount saOwnerPays = (QUALITY_ONE == uOfferRate)
|
||||
@@ -3022,7 +3025,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker
|
||||
{
|
||||
// Only provide funded offers and offers of the taker.
|
||||
Json::Value& jvOf = jvOffers.append (jvOffer);
|
||||
jvOf["quality"] = saDirRate.getText ();
|
||||
jvOf[jss::quality] = saDirRate.getText ();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3054,7 +3057,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker
|
||||
// FIXME : support iLimit.
|
||||
void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTakerPaysCurrencyID, const uint160& uTakerPaysIssuerID, const uint160& uTakerGetsCurrencyID, const uint160& uTakerGetsIssuerID, const uint160& uTakerID, const bool bProof, const unsigned int iLimit, const Json::Value& jvMarker, Json::Value& jvResult)
|
||||
{
|
||||
Json::Value& jvOffers = (jvResult["offers"] = Json::Value (Json::arrayValue));
|
||||
Json::Value& jvOffers = (jvResult[jss::offers] = Json::Value (Json::arrayValue));
|
||||
|
||||
std::map<uint160, STAmount> umBalance;
|
||||
|
||||
@@ -3151,8 +3154,8 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker
|
||||
|
||||
saTakerGetsFunded = saOwnerFundsLimit;
|
||||
|
||||
saTakerGetsFunded.setJson (jvOffer["taker_gets_funded"]);
|
||||
std::min (saTakerPays, STAmount::multiply (saTakerGetsFunded, saDirRate, saTakerPays)).setJson (jvOffer["taker_pays_funded"]);
|
||||
saTakerGetsFunded.setJson (jvOffer[jss::taker_gets_funded]);
|
||||
std::min (saTakerPays, STAmount::multiply (saTakerGetsFunded, saDirRate, saTakerPays)).setJson (jvOffer[jss::taker_pays_funded]);
|
||||
}
|
||||
|
||||
STAmount saOwnerPays = (QUALITY_ONE == uOfferRate)
|
||||
@@ -3165,7 +3168,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker
|
||||
{
|
||||
// Only provide funded offers and offers of the taker.
|
||||
Json::Value& jvOf = jvOffers.append (jvOffer);
|
||||
jvOf["quality"] = saDirRate.getText ();
|
||||
jvOf[jss::quality] = saDirRate.getText ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "../ripple_net/ripple_net.h"
|
||||
#include "../ripple_rpc/ripple_rpc.h"
|
||||
#include "../ripple_websocket/ripple_websocket.h"
|
||||
#include "../ripple/common/jsonrpc_fields.h"
|
||||
|
||||
// This .cpp will end up including all of the public header
|
||||
// material in Ripple since it holds the Application object.
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "ripple_app.h"
|
||||
#include "../ripple_net/ripple_net.h"
|
||||
#include "../ripple/common/jsonrpc_fields.h"
|
||||
|
||||
#include "../ripple/common/seconds_clock.h"
|
||||
#include "../ripple/peerfinder/ripple_peerfinder.h"
|
||||
|
||||
@@ -57,20 +57,20 @@ Json::Value RPCHandler::doRpcCommand (const std::string& strMethod, Json::Value
|
||||
return logRPCError (rpcError (rpcINVALID_PARAMS));
|
||||
|
||||
// Provide the JSON-RPC method as the field "command" in the request.
|
||||
params["command"] = strMethod;
|
||||
params[jss::command] = strMethod;
|
||||
|
||||
Json::Value jvResult = doCommand (params, iRole, loadType);
|
||||
|
||||
// Always report "status". On an error report the request as received.
|
||||
if (jvResult.isMember ("error"))
|
||||
{
|
||||
jvResult["status"] = "error";
|
||||
jvResult["request"] = params;
|
||||
jvResult[jss::status] = jss::error;
|
||||
jvResult[jss::request] = params;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["status"] = "success";
|
||||
jvResult[jss::status] = jss::success;
|
||||
}
|
||||
|
||||
return logRPCError (jvResult);
|
||||
@@ -103,7 +103,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, Resourc
|
||||
if (!params.isMember ("command"))
|
||||
return rpcError (rpcCOMMAND_MISSING);
|
||||
|
||||
std::string strCommand = params["command"].asString ();
|
||||
std::string strCommand = params[jss::command].asString ();
|
||||
|
||||
WriteLog (lsTRACE, RPCHandler) << "COMMAND:" << strCommand;
|
||||
WriteLog (lsTRACE, RPCHandler) << "REQUEST:" << params;
|
||||
@@ -232,7 +232,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, Resourc
|
||||
// Probably got a string.
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
jvResult["message"] = jvRaw;
|
||||
jvResult[jss::message] = jvRaw;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -132,18 +132,18 @@ Json::Value WSConnection::invokeCommand (Json::Value& jvRequest)
|
||||
|
||||
// Requests without "command" are invalid.
|
||||
//
|
||||
if (!jvRequest.isMember ("command"))
|
||||
if (!jvRequest.isMember (jss::command))
|
||||
{
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
jvResult["type"] = "response";
|
||||
jvResult["status"] = "error";
|
||||
jvResult["error"] = "missingCommand";
|
||||
jvResult["request"] = jvRequest;
|
||||
jvResult[jss::type] = jss::response;
|
||||
jvResult[jss::status] = jss::error;
|
||||
jvResult[jss::error] = jss::missingCommand;
|
||||
jvResult[jss::request] = jvRequest;
|
||||
|
||||
if (jvRequest.isMember ("id"))
|
||||
if (jvRequest.isMember (jss::id))
|
||||
{
|
||||
jvResult["id"] = jvRequest["id"];
|
||||
jvResult[jss::id] = jvRequest[jss::id];
|
||||
}
|
||||
|
||||
getConsumer().charge (Resource::feeInvalidRPC);
|
||||
@@ -162,17 +162,17 @@ Json::Value WSConnection::invokeCommand (Json::Value& jvRequest)
|
||||
|
||||
if (Config::FORBID == role)
|
||||
{
|
||||
jvResult["result"] = rpcError (rpcFORBIDDEN);
|
||||
jvResult[jss::result] = rpcError (rpcFORBIDDEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["result"] = mRPCHandler.doCommand (jvRequest, role, loadType);
|
||||
jvResult[jss::result] = mRPCHandler.doCommand (jvRequest, role, loadType);
|
||||
}
|
||||
|
||||
getConsumer().charge (loadType);
|
||||
if (getConsumer().warn ())
|
||||
{
|
||||
jvResult["warning"] = "load";
|
||||
jvResult[jss::warning] = jss::load;
|
||||
}
|
||||
|
||||
// Currently we will simply unwrap errors returned by the RPC
|
||||
@@ -180,24 +180,24 @@ Json::Value WSConnection::invokeCommand (Json::Value& jvRequest)
|
||||
// consistent.
|
||||
//
|
||||
// Regularize result. This is duplicate code.
|
||||
if (jvResult["result"].isMember ("error"))
|
||||
if (jvResult[jss::result].isMember (jss::error))
|
||||
{
|
||||
jvResult = jvResult["result"];
|
||||
jvResult["status"] = "error";
|
||||
jvResult["request"] = jvRequest;
|
||||
jvResult = jvResult[jss::result];
|
||||
jvResult[jss::status] = jss::error;
|
||||
jvResult[jss::request] = jvRequest;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["status"] = "success";
|
||||
jvResult[jss::status] = jss::success;
|
||||
}
|
||||
|
||||
if (jvRequest.isMember ("id"))
|
||||
if (jvRequest.isMember (jss::id))
|
||||
{
|
||||
jvResult["id"] = jvRequest["id"];
|
||||
jvResult[jss::id] = jvRequest[jss::id];
|
||||
}
|
||||
|
||||
jvResult["type"] = "response";
|
||||
jvResult[jss::type] = jss::response;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -368,8 +368,8 @@ public:
|
||||
{
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
jvResult["type"] = "error";
|
||||
jvResult["error"] = "wsTextRequired"; // We only accept text messages.
|
||||
jvResult[jss::type] = jss::error;
|
||||
jvResult[jss::error] = "wsTextRequired"; // We only accept text messages.
|
||||
|
||||
send (cpClient, jvResult, false);
|
||||
}
|
||||
@@ -377,17 +377,17 @@ public:
|
||||
{
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
jvResult["type"] = "error";
|
||||
jvResult["error"] = "jsonInvalid"; // Received invalid json.
|
||||
jvResult["value"] = mpMessage->get_payload ();
|
||||
jvResult[jss::type] = jss::error;
|
||||
jvResult[jss::error] = "jsonInvalid"; // Received invalid json.
|
||||
jvResult[jss::value] = mpMessage->get_payload ();
|
||||
|
||||
send (cpClient, jvResult, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jvRequest.isMember ("command"))
|
||||
if (jvRequest.isMember (jss::command))
|
||||
{
|
||||
Json::Value& jCmd = jvRequest["command"];
|
||||
Json::Value& jCmd = jvRequest[jss::command];
|
||||
if (jCmd.isString())
|
||||
job.rename (std::string ("WSClient::") + jCmd.asString());
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef RIPPLE_LOADFEETRACKIMP_H_INCLUDED
|
||||
#define RIPPLE_LOADFEETRACKIMP_H_INCLUDED
|
||||
|
||||
#include "../../ripple/common/jsonrpc_fields.h"
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class LoadFeeTrackImp : public LoadFeeTrack
|
||||
@@ -187,10 +189,10 @@ public:
|
||||
ScopedLockType sl (mLock);
|
||||
|
||||
// base_fee = The cost to send a "reference" transaction under no load, in millionths of a Ripple
|
||||
j["base_fee"] = Json::Value::UInt (baseFee);
|
||||
j[jss::base_fee] = Json::Value::UInt (baseFee);
|
||||
|
||||
// load_fee = The cost to send a "reference" transaction now, in millionths of a Ripple
|
||||
j["load_fee"] = Json::Value::UInt (
|
||||
j[jss::load_fee] = Json::Value::UInt (
|
||||
mulDiv (baseFee, std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee), lftNormalFee));
|
||||
}
|
||||
|
||||
|
||||
@@ -62,12 +62,14 @@ static const int f = initFields ();
|
||||
|
||||
|
||||
SField::SField (SerializedTypeID tid, int fv) : fieldCode (FIELD_CODE (tid, fv)), fieldType (tid), fieldValue (fv),
|
||||
fieldMeta (sMD_Default), fieldNum (++num), signingField (true)
|
||||
fieldMeta (sMD_Default), fieldNum (++num), signingField (true), jsonName (nullptr)
|
||||
{
|
||||
// call with the map mutex
|
||||
fieldName = beast::lexicalCast <std::string> (tid) + "/" +
|
||||
beast::lexicalCast <std::string> (fv);
|
||||
codeToField[fieldCode] = this;
|
||||
rawJsonName = getName ();
|
||||
jsonName = Json::StaticString (rawJsonName.c_str ());
|
||||
assert ((fv != 1) || ((tid != STI_ARRAY) && (tid != STI_OBJECT)));
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,11 @@ public:
|
||||
int fieldMeta;
|
||||
int fieldNum;
|
||||
bool signingField;
|
||||
std::string rawJsonName;
|
||||
Json::StaticString jsonName;
|
||||
|
||||
SField(SField const&) = delete;
|
||||
SField& operator=(SField const&) = delete;
|
||||
|
||||
SField (int fc, SerializedTypeID tid, int fv, const char* fn)
|
||||
: fieldCode (fc)
|
||||
@@ -81,6 +86,8 @@ public:
|
||||
, fieldName (fn)
|
||||
, fieldMeta (sMD_Default)
|
||||
, signingField (true)
|
||||
, rawJsonName (getName ())
|
||||
, jsonName (rawJsonName.c_str ())
|
||||
{
|
||||
StaticScopedLockType sl (getMutex ());
|
||||
|
||||
@@ -96,6 +103,8 @@ public:
|
||||
, fieldName (fn)
|
||||
, fieldMeta (sMD_Default)
|
||||
, signingField (true)
|
||||
, rawJsonName (getName ())
|
||||
, jsonName (rawJsonName.c_str ())
|
||||
{
|
||||
StaticScopedLockType sl (getMutex ());
|
||||
|
||||
@@ -110,6 +119,8 @@ public:
|
||||
, fieldValue (0)
|
||||
, fieldMeta (sMD_Never)
|
||||
, signingField (true)
|
||||
, rawJsonName (getName ())
|
||||
, jsonName (rawJsonName.c_str ())
|
||||
{
|
||||
StaticScopedLockType sl (getMutex ());
|
||||
fieldNum = ++num;
|
||||
@@ -134,6 +145,11 @@ public:
|
||||
return !fieldName.empty ();
|
||||
}
|
||||
|
||||
Json::StaticString const& getJsonName () const
|
||||
{
|
||||
return jsonName;
|
||||
}
|
||||
|
||||
bool isGeneric () const
|
||||
{
|
||||
return fieldCode == 0;
|
||||
|
||||
@@ -123,9 +123,9 @@ STAmount::STAmount (SField::ref n, const Json::Value& v)
|
||||
"', issuer='" << v["issuer"].asString () <<
|
||||
"')";
|
||||
|
||||
value = v["value"];
|
||||
currency = v["currency"];
|
||||
issuer = v["issuer"];
|
||||
value = v[jss::value];
|
||||
currency = v[jss::currency];
|
||||
issuer = v[jss::issuer];
|
||||
}
|
||||
else if (v.isArray ())
|
||||
{
|
||||
@@ -1131,9 +1131,9 @@ void STAmount::setJson (Json::Value& elem) const
|
||||
{
|
||||
// It is an error for currency or issuer not to be specified for valid json.
|
||||
|
||||
elem["value"] = getText ();
|
||||
elem["currency"] = getHumanCurrency ();
|
||||
elem["issuer"] = RippleAddress::createHumanAccountID (mIssuer);
|
||||
elem[jss::value] = getText ();
|
||||
elem[jss::currency] = getHumanCurrency ();
|
||||
elem[jss::issuer] = RippleAddress::createHumanAccountID (mIssuer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1080,7 +1080,7 @@ Json::Value STObject::getJson (int options) const
|
||||
if (!it.getFName ().hasName ())
|
||||
ret[beast::lexicalCast <std::string> (index)] = it.getJson (options);
|
||||
else
|
||||
ret[it.getName ()] = it.getJson (options);
|
||||
ret[it.getJsonName ()] = it.getJson (options);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -505,17 +505,17 @@ Json::Value STPath::getJson (int) const
|
||||
Json::Value elem (Json::objectValue);
|
||||
int iType = it.getNodeType ();
|
||||
|
||||
elem["type"] = iType;
|
||||
elem["type_hex"] = strHex (iType);
|
||||
elem[jss::type] = iType;
|
||||
elem[jss::type_hex] = strHex (iType);
|
||||
|
||||
if (iType & STPathElement::typeAccount)
|
||||
elem["account"] = RippleAddress::createHumanAccountID (it.getAccountID ());
|
||||
elem[jss::account] = RippleAddress::createHumanAccountID (it.getAccountID ());
|
||||
|
||||
if (iType & STPathElement::typeCurrency)
|
||||
elem["currency"] = STAmount::createHumanCurrency (it.getCurrency ());
|
||||
elem[jss::currency] = STAmount::createHumanCurrency (it.getCurrency ());
|
||||
|
||||
if (iType & STPathElement::typeIssuer)
|
||||
elem["issuer"] = RippleAddress::createHumanAccountID (it.getIssuerID ());
|
||||
elem[jss::issuer] = RippleAddress::createHumanAccountID (it.getIssuerID ());
|
||||
|
||||
ret.append (elem);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,10 @@ public:
|
||||
{
|
||||
return fName->fieldName;
|
||||
}
|
||||
Json::StaticString const& getJsonName () const
|
||||
{
|
||||
return fName->getJsonName ();
|
||||
}
|
||||
|
||||
virtual SerializedTypeID getSType () const
|
||||
{
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "../ripple/sslutil/ripple_sslutil.h"
|
||||
#include "../ripple_rpc/api/ErrorCodes.h"
|
||||
#include "../ripple/common/jsonrpc_fields.h"
|
||||
|
||||
// VFALCO TODO fix these warnings!
|
||||
#if BEAST_MSVC
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
// still uses the unity style inclusion.
|
||||
//
|
||||
#include "../ripple_rpc/api/ErrorCodes.h"
|
||||
#include "../ripple/common/jsonrpc_fields.h"
|
||||
|
||||
#include "basics/HTTPRequest.cpp"
|
||||
#include "basics/HTTPClient.cpp"
|
||||
|
||||
@@ -39,8 +39,8 @@ Json::Value JSONRPCError (int code, const std::string& message)
|
||||
{
|
||||
Json::Value error (Json::objectValue);
|
||||
|
||||
error["code"] = Json::Value (code);
|
||||
error["message"] = Json::Value (message);
|
||||
error[jss::code] = Json::Value (code);
|
||||
error[jss::message] = Json::Value (message);
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -297,9 +297,9 @@ bool HTTPAuthorized (const std::map<std::string, std::string>& mapHeaders)
|
||||
std::string JSONRPCRequest (const std::string& strMethod, const Json::Value& params, const Json::Value& id)
|
||||
{
|
||||
Json::Value request;
|
||||
request["method"] = strMethod;
|
||||
request["params"] = params;
|
||||
request["id"] = id;
|
||||
request[jss::method] = strMethod;
|
||||
request[jss::params] = params;
|
||||
request[jss::id] = id;
|
||||
Json::FastWriter writer;
|
||||
return writer.write (request) + "\n";
|
||||
}
|
||||
@@ -307,7 +307,7 @@ std::string JSONRPCRequest (const std::string& strMethod, const Json::Value& par
|
||||
std::string JSONRPCReply (const Json::Value& result, const Json::Value& error, const Json::Value& id)
|
||||
{
|
||||
Json::Value reply (Json::objectValue);
|
||||
reply["result"] = result;
|
||||
reply[jss::result] = result;
|
||||
//reply["error"]=error;
|
||||
//reply["id"]=id;
|
||||
Json::FastWriter writer;
|
||||
@@ -318,7 +318,7 @@ void ErrorReply (std::ostream& stream, const Json::Value& objError, const Json::
|
||||
{
|
||||
// Send error reply from json-rpc error object
|
||||
int nStatus = 500;
|
||||
int code = objError["code"].asInt ();
|
||||
int code = objError[jss::code].asInt ();
|
||||
|
||||
if (code == -32600) nStatus = 400;
|
||||
else if (code == -32601) nStatus = 404;
|
||||
|
||||
@@ -36,12 +36,12 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, Resource::Charge& lo
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!params.isMember ("account"))
|
||||
if (!params.isMember (jss::account))
|
||||
return RPC::missing_field_error ("account");
|
||||
|
||||
std::string strIdent = params["account"].asString ();
|
||||
bool bIndex = params.isMember ("account_index");
|
||||
int iIndex = bIndex ? params["account_index"].asUInt () : 0;
|
||||
std::string strIdent = params[jss::account].asString ();
|
||||
bool bIndex = params.isMember (jss::account_index);
|
||||
int iIndex = bIndex ? params[jss::account_index].asUInt () : 0;
|
||||
|
||||
RippleAddress raAccount;
|
||||
|
||||
@@ -50,18 +50,18 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, Resource::Charge& lo
|
||||
if (!jvResult.empty ())
|
||||
return jvResult;
|
||||
|
||||
std::string strPeer = params.isMember ("peer") ? params["peer"].asString () : "";
|
||||
bool bPeerIndex = params.isMember ("peer_index");
|
||||
int iPeerIndex = bIndex ? params["peer_index"].asUInt () : 0;
|
||||
std::string strPeer = params.isMember (jss::peer) ? params[jss::peer].asString () : "";
|
||||
bool bPeerIndex = params.isMember (jss::peer_index);
|
||||
int iPeerIndex = bIndex ? params[jss::peer_index].asUInt () : 0;
|
||||
|
||||
RippleAddress raPeer;
|
||||
|
||||
if (!strPeer.empty ())
|
||||
{
|
||||
jvResult["peer"] = raAccount.humanAccountID ();
|
||||
jvResult[jss::peer] = raAccount.humanAccountID ();
|
||||
|
||||
if (bPeerIndex)
|
||||
jvResult["peer_index"] = iPeerIndex;
|
||||
jvResult[jss::peer_index] = iPeerIndex;
|
||||
|
||||
jvResult = RPC::accountFromString (lpLedger, raPeer, bPeerIndex, strPeer, iPeerIndex, false, *mNetOps);
|
||||
|
||||
@@ -73,8 +73,8 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, Resource::Charge& lo
|
||||
{
|
||||
AccountItems rippleLines (raAccount.getAccountID (), lpLedger, AccountItem::pointer (new RippleState ()));
|
||||
|
||||
jvResult["account"] = raAccount.humanAccountID ();
|
||||
Json::Value& jsonLines = (jvResult["lines"] = Json::arrayValue);
|
||||
jvResult[jss::account] = raAccount.humanAccountID ();
|
||||
Json::Value& jsonLines = (jvResult[jss::lines] = Json::arrayValue);
|
||||
|
||||
|
||||
BOOST_FOREACH (AccountItem::ref item, rippleLines.getItems ())
|
||||
@@ -89,23 +89,23 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, Resource::Charge& lo
|
||||
|
||||
Json::Value& jPeer = jsonLines.append (Json::objectValue);
|
||||
|
||||
jPeer["account"] = RippleAddress::createHumanAccountID (line->getAccountIDPeer ());
|
||||
jPeer[jss::account] = RippleAddress::createHumanAccountID (line->getAccountIDPeer ());
|
||||
// Amount reported is positive if current account holds other account's IOUs.
|
||||
// Amount reported is negative if other account holds current account's IOUs.
|
||||
jPeer["balance"] = saBalance.getText ();
|
||||
jPeer["currency"] = saBalance.getHumanCurrency ();
|
||||
jPeer["limit"] = saLimit.getText ();
|
||||
jPeer["limit_peer"] = saLimitPeer.getText ();
|
||||
jPeer["quality_in"] = static_cast<Json::UInt> (line->getQualityIn ());
|
||||
jPeer["quality_out"] = static_cast<Json::UInt> (line->getQualityOut ());
|
||||
jPeer[jss::balance] = saBalance.getText ();
|
||||
jPeer[jss::currency] = saBalance.getHumanCurrency ();
|
||||
jPeer[jss::limit] = saLimit.getText ();
|
||||
jPeer[jss::limit_peer] = saLimitPeer.getText ();
|
||||
jPeer[jss::quality_in] = static_cast<Json::UInt> (line->getQualityIn ());
|
||||
jPeer[jss::quality_out] = static_cast<Json::UInt> (line->getQualityOut ());
|
||||
if (line->getAuth())
|
||||
jPeer["authorized"] = true;
|
||||
jPeer[jss::authorized] = true;
|
||||
if (line->getAuthPeer())
|
||||
jPeer["peer_authorized"] = true;
|
||||
jPeer[jss::peer_authorized] = true;
|
||||
if (line->getNoRipple())
|
||||
jPeer["no_ripple"] = true;
|
||||
jPeer[jss::no_ripple] = true;
|
||||
if (line->getNoRipplePeer())
|
||||
jPeer["no_ripple_peer"] = true;
|
||||
jPeer[jss::no_ripple_peer] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ static void offerAdder (Json::Value& jvLines, SLE::ref offer)
|
||||
if (offer->getType () == ltOFFER)
|
||||
{
|
||||
Json::Value& obj = jvLines.append (Json::objectValue);
|
||||
offer->getFieldAmount (sfTakerPays).setJson (obj["taker_pays"]);
|
||||
offer->getFieldAmount (sfTakerGets).setJson (obj["taker_gets"]);
|
||||
obj["seq"] = offer->getFieldU32 (sfSequence);
|
||||
obj["flags"] = offer->getFieldU32 (sfFlags);
|
||||
offer->getFieldAmount (sfTakerPays).setJson (obj[jss::taker_pays]);
|
||||
offer->getFieldAmount (sfTakerGets).setJson (obj[jss::taker_gets]);
|
||||
obj[jss::seq] = offer->getFieldU32 (sfSequence);
|
||||
obj[jss::flags] = offer->getFieldU32 (sfFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,12 +48,12 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, Resource::Charge& l
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!params.isMember ("account"))
|
||||
if (!params.isMember (jss::account))
|
||||
return RPC::missing_field_error ("account");
|
||||
|
||||
std::string strIdent = params["account"].asString ();
|
||||
bool bIndex = params.isMember ("account_index");
|
||||
int iIndex = bIndex ? params["account_index"].asUInt () : 0;
|
||||
std::string strIdent = params[jss::account].asString ();
|
||||
bool bIndex = params.isMember (jss::account_index);
|
||||
int iIndex = bIndex ? params[jss::account_index].asUInt () : 0;
|
||||
|
||||
RippleAddress raAccount;
|
||||
|
||||
@@ -64,15 +64,15 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, Resource::Charge& l
|
||||
|
||||
// Get info on account.
|
||||
|
||||
jvResult["account"] = raAccount.humanAccountID ();
|
||||
jvResult[jss::account] = raAccount.humanAccountID ();
|
||||
|
||||
if (bIndex)
|
||||
jvResult["account_index"] = iIndex;
|
||||
jvResult[jss::account_index] = iIndex;
|
||||
|
||||
if (!lpLedger->hasAccount (raAccount))
|
||||
return rpcError (rpcACT_NOT_FOUND);
|
||||
|
||||
Json::Value& jvsOffers = (jvResult["offers"] = Json::arrayValue);
|
||||
Json::Value& jvsOffers = (jvResult[jss::offers] = Json::arrayValue);
|
||||
lpLedger->visitAccountItems (raAccount.getAccountID (), BIND_TYPE (&offerAdder, boost::ref (jvsOffers), P_1));
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
|
||||
@@ -34,7 +34,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
RippleAddress raAccount;
|
||||
int limit = params.isMember ("limit") ? params["limit"].asUInt () : -1;
|
||||
int limit = params.isMember (jss::limit) ? params[jss::limit].asUInt () : -1;
|
||||
bool bBinary = params.isMember ("binary") && params["binary"].asBool ();
|
||||
bool bForward = params.isMember ("forward") && params["forward"].asBool ();
|
||||
std::uint32_t uLedgerMin;
|
||||
@@ -84,9 +84,9 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
|
||||
Json::Value resumeToken;
|
||||
|
||||
if (params.isMember("marker"))
|
||||
if (params.isMember(jss::marker))
|
||||
{
|
||||
resumeToken = params["marker"];
|
||||
resumeToken = params[jss::marker];
|
||||
}
|
||||
|
||||
#ifndef BEAST_DEBUG
|
||||
@@ -113,7 +113,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
jvObj["tx_blob"] = std::get<0> (*it);
|
||||
jvObj["meta"] = std::get<1> (*it);
|
||||
jvObj["ledger_index"] = uLedgerIndex;
|
||||
jvObj["validated"] = bValidated && uValidatedMin <= uLedgerIndex && uValidatedMax >= uLedgerIndex;
|
||||
jvObj[jss::validated] = bValidated && uValidatedMin <= uLedgerIndex && uValidatedMax >= uLedgerIndex;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -127,26 +127,26 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
Json::Value& jvObj = jvTxns.append (Json::objectValue);
|
||||
|
||||
if (it->first)
|
||||
jvObj["tx"] = it->first->getJson (1);
|
||||
jvObj[jss::tx] = it->first->getJson (1);
|
||||
|
||||
if (it->second)
|
||||
{
|
||||
std::uint32_t uLedgerIndex = it->second->getLgrSeq ();
|
||||
|
||||
jvObj["meta"] = it->second->getJson (0);
|
||||
jvObj["validated"] = bValidated && uValidatedMin <= uLedgerIndex && uValidatedMax >= uLedgerIndex;
|
||||
jvObj[jss::meta] = it->second->getJson (0);
|
||||
jvObj[jss::validated] = bValidated && uValidatedMin <= uLedgerIndex && uValidatedMax >= uLedgerIndex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Add information about the original query
|
||||
ret["ledger_index_min"] = uLedgerMin;
|
||||
ret["ledger_index_max"] = uLedgerMax;
|
||||
if (params.isMember ("limit"))
|
||||
ret["limit"] = limit;
|
||||
ret[jss::ledger_index_min] = uLedgerMin;
|
||||
ret[jss::ledger_index_max] = uLedgerMax;
|
||||
if (params.isMember (jss::limit))
|
||||
ret[jss::limit] = limit;
|
||||
if (!resumeToken.isNull())
|
||||
ret["marker"] = resumeToken;
|
||||
ret[jss::marker] = resumeToken;
|
||||
|
||||
return ret;
|
||||
#ifndef BEAST_DEBUG
|
||||
|
||||
@@ -54,7 +54,7 @@ Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
jvResult["error"] = "invalidTransaction";
|
||||
jvResult[jss::error] = "invalidTransaction";
|
||||
jvResult["error_exception"] = e.what ();
|
||||
|
||||
return jvResult;
|
||||
@@ -68,7 +68,7 @@ Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
jvResult["error"] = "internalTransaction";
|
||||
jvResult[jss::error] = "internalTransaction";
|
||||
jvResult["error_exception"] = e.what ();
|
||||
|
||||
return jvResult;
|
||||
@@ -81,8 +81,8 @@ Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
jvResult["error"] = "internalSubmit";
|
||||
jvResult["error_exception"] = e.what ();
|
||||
jvResult[jss::error] = "internalSubmit";
|
||||
jvResult[jss::error_exception] = e.what ();
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
@@ -90,8 +90,8 @@ Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType
|
||||
|
||||
try
|
||||
{
|
||||
jvResult["tx_json"] = tpTrans->getJson (0);
|
||||
jvResult["tx_blob"] = strHex (tpTrans->getSTransaction ()->getSerializer ().peekData ());
|
||||
jvResult[jss::tx_json] = tpTrans->getJson (0);
|
||||
jvResult[jss::tx_blob] = strHex (tpTrans->getSTransaction ()->getSerializer ().peekData ());
|
||||
|
||||
if (temUNCERTAIN != tpTrans->getResult ())
|
||||
{
|
||||
@@ -100,17 +100,17 @@ Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType
|
||||
|
||||
transResultInfo (tpTrans->getResult (), sToken, sHuman);
|
||||
|
||||
jvResult["engine_result"] = sToken;
|
||||
jvResult["engine_result_code"] = tpTrans->getResult ();
|
||||
jvResult["engine_result_message"] = sHuman;
|
||||
jvResult[jss::engine_result] = sToken;
|
||||
jvResult[jss::engine_result_code] = tpTrans->getResult ();
|
||||
jvResult[jss::engine_result_message] = sHuman;
|
||||
}
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
jvResult["error"] = "internalJson";
|
||||
jvResult["error_exception"] = e.what ();
|
||||
jvResult[jss::error] = "internalJson";
|
||||
jvResult[jss::error_exception] = e.what ();
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
|
||||
InfoSub::pointer ispSub;
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
std::uint32_t uLedgerIndex = params.isMember ("ledger_index") && params["ledger_index"].isNumeric ()
|
||||
? params["ledger_index"].asUInt ()
|
||||
std::uint32_t uLedgerIndex = params.isMember (jss::ledger_index) && params[jss::ledger_index].isNumeric ()
|
||||
? params[jss::ledger_index].asUInt ()
|
||||
: 0;
|
||||
|
||||
if (!mInfoSub && !params.isMember ("url"))
|
||||
@@ -120,12 +120,12 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["error"] = "unknownStream";
|
||||
jvResult[jss::error] = "unknownStream";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["error"] = "malformedStream";
|
||||
jvResult[jss::error] = "malformedStream";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
|
||||
if (usnaAccoundIds.empty ())
|
||||
{
|
||||
jvResult["error"] = "malformedAccount";
|
||||
jvResult[jss::error] = "malformedAccount";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -171,7 +171,7 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
|
||||
if (usnaAccoundIds.empty ())
|
||||
{
|
||||
jvResult["error"] = "malformedAccount";
|
||||
jvResult[jss::error] = "malformedAccount";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -197,10 +197,10 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
Json::Value& jvSubRequest = *it;
|
||||
|
||||
if (!jvSubRequest.isObject ()
|
||||
|| !jvSubRequest.isMember ("taker_pays")
|
||||
|| !jvSubRequest.isMember ("taker_gets")
|
||||
|| !jvSubRequest["taker_pays"].isObject ()
|
||||
|| !jvSubRequest["taker_gets"].isObject ())
|
||||
|| !jvSubRequest.isMember (jss::taker_pays)
|
||||
|| !jvSubRequest.isMember (jss::taker_gets)
|
||||
|| !jvSubRequest[jss::taker_pays].isObject ()
|
||||
|| !jvSubRequest[jss::taker_gets].isObject ())
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
// VFALCO TODO Use RippleAsset here
|
||||
@@ -214,21 +214,21 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
bool bSnapshot = (jvSubRequest.isMember ("snapshot") && jvSubRequest["snapshot"].asBool ())
|
||||
|| (jvSubRequest.isMember ("state_now") && jvSubRequest["state_now"].asBool ()); // DEPRECATED
|
||||
|
||||
Json::Value taker_pays = jvSubRequest["taker_pays"];
|
||||
Json::Value taker_gets = jvSubRequest["taker_gets"];
|
||||
Json::Value taker_pays = jvSubRequest[jss::taker_pays];
|
||||
Json::Value taker_gets = jvSubRequest[jss::taker_gets];
|
||||
|
||||
// Parse mandatory currency.
|
||||
if (!taker_pays.isMember ("currency")
|
||||
|| !STAmount::currencyFromString (pay_currency, taker_pays["currency"].asString ()))
|
||||
if (!taker_pays.isMember (jss::currency)
|
||||
|| !STAmount::currencyFromString (pay_currency, taker_pays[jss::currency].asString ()))
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency.";
|
||||
|
||||
return rpcError (rpcSRC_CUR_MALFORMED);
|
||||
}
|
||||
// Parse optional issuer.
|
||||
else if (((taker_pays.isMember ("issuer"))
|
||||
&& (!taker_pays["issuer"].isString ()
|
||||
|| !STAmount::issuerFromString (pay_issuer, taker_pays["issuer"].asString ())))
|
||||
else if (((taker_pays.isMember (jss::issuer))
|
||||
&& (!taker_pays[jss::issuer].isString ()
|
||||
|| !STAmount::issuerFromString (pay_issuer, taker_pays[jss::issuer].asString ())))
|
||||
// Don't allow illegal issuers.
|
||||
|| (!pay_currency != !pay_issuer)
|
||||
|| ACCOUNT_ONE == pay_issuer)
|
||||
@@ -239,17 +239,17 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
}
|
||||
|
||||
// Parse mandatory currency.
|
||||
if (!taker_gets.isMember ("currency")
|
||||
|| !STAmount::currencyFromString (get_currency, taker_gets["currency"].asString ()))
|
||||
if (!taker_gets.isMember (jss::currency)
|
||||
|| !STAmount::currencyFromString (get_currency, taker_gets[jss::currency].asString ()))
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency.";
|
||||
|
||||
return rpcError (rpcSRC_CUR_MALFORMED);
|
||||
}
|
||||
// Parse optional issuer.
|
||||
else if (((taker_gets.isMember ("issuer"))
|
||||
&& (!taker_gets["issuer"].isString ()
|
||||
|| !STAmount::issuerFromString (get_issuer, taker_gets["issuer"].asString ())))
|
||||
else if (((taker_gets.isMember (jss::issuer))
|
||||
&& (!taker_gets[jss::issuer].isString ()
|
||||
|| !STAmount::issuerFromString (get_issuer, taker_gets[jss::issuer].asString ())))
|
||||
// Don't allow illegal issuers.
|
||||
|| (!get_currency != !get_issuer)
|
||||
|| ACCOUNT_ONE == get_issuer)
|
||||
@@ -311,11 +311,11 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
|
||||
mNetOps->getBookPage (lpLedger, pay_currency, pay_issuer, get_currency, get_issuer, raTakerID.getAccountID (), false, 0, jvMarker, jvBids);
|
||||
|
||||
if (jvBids.isMember ("offers")) jvResult["bids"] = jvBids["offers"];
|
||||
if (jvBids.isMember (jss::offers)) jvResult[jss::bids] = jvBids[jss::offers];
|
||||
|
||||
mNetOps->getBookPage (lpLedger, get_currency, get_issuer, pay_currency, pay_issuer, raTakerID.getAccountID (), false, 0, jvMarker, jvAsks);
|
||||
|
||||
if (jvAsks.isMember ("offers")) jvResult["asks"] = jvAsks["offers"];
|
||||
if (jvAsks.isMember (jss::offers)) jvResult[jss::asks] = jvAsks[jss::offers];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -27,12 +27,12 @@ Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Ap
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
if (!params.isMember ("transaction"))
|
||||
if (!params.isMember (jss::transaction))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
bool binary = params.isMember ("binary") && params["binary"].asBool ();
|
||||
bool binary = params.isMember (jss::binary) && params[jss::binary].asBool ();
|
||||
|
||||
std::string strTransaction = params["transaction"].asString ();
|
||||
std::string strTransaction = params[jss::transaction].asString ();
|
||||
|
||||
if (Transaction::isHexTxID (strTransaction))
|
||||
{
|
||||
@@ -46,7 +46,7 @@ Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Ap
|
||||
|
||||
#ifdef READY_FOR_NEW_TX_FORMAT
|
||||
Json::Value ret;
|
||||
ret["transaction"] = txn->getJson (0, binary);
|
||||
ret[jss::transaction] = txn->getJson (0, binary);
|
||||
#else
|
||||
Json::Value ret = txn->getJson (0, binary);
|
||||
#endif
|
||||
@@ -65,7 +65,7 @@ Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Ap
|
||||
|
||||
if (lgr->getMetaHex (txid, meta))
|
||||
{
|
||||
ret["meta"] = meta;
|
||||
ret[jss::meta] = meta;
|
||||
okay = true;
|
||||
}
|
||||
}
|
||||
@@ -76,12 +76,12 @@ Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Ap
|
||||
if (lgr->getTransactionMeta (txid, set))
|
||||
{
|
||||
okay = true;
|
||||
ret["meta"] = set->getJson (0);
|
||||
ret[jss::meta] = set->getJson (0);
|
||||
}
|
||||
}
|
||||
|
||||
if (okay)
|
||||
ret["validated"] = mNetOps->isValidated (lgr);
|
||||
ret[jss::validated] = mNetOps->isValidated (lgr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user