Skip to content

Commit

Permalink
[FOLD] Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelportilla committed Jul 16, 2018
1 parent 933bcac commit 9b2f2b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/ripple/app/main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ int run (int argc, char** argv)
if (vm.count("nodetoshard"))
config->nodeToShard = true;

if (vm.count ("validateShards "))
if (vm.count ("validateShards"))
config->validateShards = true;

if (vm.count ("ledger"))
Expand Down
37 changes: 19 additions & 18 deletions src/ripple/net/impl/RPCCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,32 +153,33 @@ class RPCParser

Json::Value parseDownloadShard(Json::Value const& jvParams)
{
Json::Value v (Json::objectValue);
Json::Value jvResult(Json::objectValue);
unsigned int sz {jvParams.size()};
unsigned int i {0};

if (!jvParams.isMember(jss::shards) ||
!jvParams[0u].isArray() ||
jvParams[0u].size() == 0)
// If odd number of params then 'novalidate' may have been specified
if (sz & 1)
{
return rpcError(rpcINVALID_PARAMS);
using namespace boost::beast::detail;
if (iequals(jvParams[0u].asString(), "novalidate"))
++i;
else if (!iequals(jvParams[--sz].asString(), "novalidate"))
return rpcError(rpcINVALID_PARAMS);
jvResult[jss::validate] = false;
}

// Create the 'shards' array
Json::Value shards(Json::arrayValue);
for (auto i = 0; i < jvParams[0u].size(); ++i)
for (; i < sz; i += 2)
{
Json::Value shard(Json::objectValue);
shard[jss::index] = jvParams[0u][i][0u].asUInt();
shard[jss::url] = jvParams[0u][i][1u].asString();
shards.append(shard);
shard[jss::index] = jvParams[i].asUInt();
shard[jss::url] = jvParams[i + 1].asString();
shards.append(std::move(shard));
}
v[jss::shards] = shards;
jvResult[jss::shards] = std::move(shards);

if (jvParams.isMember(jss::validate))
{
if (!jvParams[1u].isBool())
return rpcError(rpcINVALID_PARAMS);
v[jss::validate] = jvParams[1u].asBool();
}
return v;
return jvResult;
}

Json::Value parseInternal (Json::Value const& jvParams)
Expand Down Expand Up @@ -1115,7 +1116,7 @@ class RPCParser
{ "connect", &RPCParser::parseConnect, 1, 2 },
{ "consensus_info", &RPCParser::parseAsIs, 0, 0 },
{ "deposit_authorized", &RPCParser::parseDepositAuthorized, 2, 3 },
{ "download_shard", &RPCParser::parseDownloadShard, 1, 2 },
{ "download_shard", &RPCParser::parseDownloadShard, 2, -1 },
{ "feature", &RPCParser::parseFeature, 0, 2 },
{ "fetch_info", &RPCParser::parseFetchInfo, 0, 1 },
{ "gateway_balances", &RPCParser::parseGatewayBalances, 1, -1 },
Expand Down

0 comments on commit 9b2f2b5

Please sign in to comment.