mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix levelization
* Move `chooseLedgerEntryType` from protocol to RPC
This commit is contained in:
committed by
Scott Schurr
parent
46004158a2
commit
96ece1b9f0
@@ -664,9 +664,58 @@ keypairForSignature(Json::Value const& params, Json::Value& error)
|
||||
return generateKeyPair (keyType, *seed);
|
||||
}
|
||||
|
||||
beast::SemanticVersion const firstVersion ("1.0.0");
|
||||
beast::SemanticVersion const goodVersion ("1.0.0");
|
||||
beast::SemanticVersion const lastVersion ("1.0.0");
|
||||
std::pair<RPC::Status, LedgerEntryType>
|
||||
chooseLedgerEntryType(Json::Value const& params)
|
||||
{
|
||||
std::pair<RPC::Status, LedgerEntryType> result{ RPC::Status::OK, ltINVALID };
|
||||
if (params.isMember(jss::type))
|
||||
{
|
||||
static
|
||||
std::array<std::pair<char const *, LedgerEntryType>, 11> const types
|
||||
{ {
|
||||
{ jss::account, ltACCOUNT_ROOT },
|
||||
{ jss::amendments, ltAMENDMENTS },
|
||||
{ jss::directory, ltDIR_NODE },
|
||||
{ jss::fee, ltFEE_SETTINGS },
|
||||
{ jss::hashes, ltLEDGER_HASHES },
|
||||
{ jss::offer, ltOFFER },
|
||||
{ jss::signer_list, ltSIGNER_LIST },
|
||||
{ jss::state, ltRIPPLE_STATE },
|
||||
{ jss::ticket, ltTICKET },
|
||||
{ jss::escrow, ltESCROW },
|
||||
{ jss::payment_channel, ltPAYCHAN }
|
||||
} };
|
||||
|
||||
auto const& p = params[jss::type];
|
||||
if (!p.isString())
|
||||
{
|
||||
result.first = RPC::Status{ rpcINVALID_PARAMS,
|
||||
"Invalid field 'type', not string." };
|
||||
assert(result.first.type() == RPC::Status::Type::error_code_i);
|
||||
return result;
|
||||
}
|
||||
|
||||
auto const filter = p.asString();
|
||||
auto iter = std::find_if(types.begin(), types.end(),
|
||||
[&filter](decltype (types.front())& t)
|
||||
{
|
||||
return t.first == filter;
|
||||
});
|
||||
if (iter == types.end())
|
||||
{
|
||||
result.first = RPC::Status{ rpcINVALID_PARAMS,
|
||||
"Invalid field 'type'." };
|
||||
assert(result.first.type() == RPC::Status::Type::error_code_i);
|
||||
return result;
|
||||
}
|
||||
result.second = iter->second;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
beast::SemanticVersion const firstVersion("1.0.0");
|
||||
beast::SemanticVersion const goodVersion("1.0.0");
|
||||
beast::SemanticVersion const lastVersion("1.0.0");
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
|
||||
Reference in New Issue
Block a user