Improve RPC error message for fee command:

* If rippled is not synced to the network, `fee` will return a
  "no network" error instead of the possibly confusing "not enabled"
  error.
* Resolves RIPD-1588
This commit is contained in:
Edward Hennis
2018-10-03 17:08:09 -04:00
committed by Mike Ellery
parent e98c76110a
commit af1697cc6a
3 changed files with 4 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ namespace ripple
{
// Bail if fee escalation is not enabled.
auto const view = context.app.openLedger().current();
BOOST_ASSERT(view);
if (!view || !view->rules().enabled(featureFeeEscalation))
{
RPC::inject_error(rpcNOT_ENABLED, context.params);

View File

@@ -77,7 +77,7 @@ Handler const handlerArray[] {
{ "gateway_balances", byRef (&doGatewayBalances), Role::USER, NO_CONDITION },
{ "get_counts", byRef (&doGetCounts), Role::ADMIN, NO_CONDITION },
{ "feature", byRef (&doFeature), Role::ADMIN, NO_CONDITION },
{ "fee", byRef (&doFee), Role::USER, NO_CONDITION },
{ "fee", byRef (&doFee), Role::USER, NEEDS_CURRENT_LEDGER },
{ "fetch_info", byRef (&doFetchInfo), Role::ADMIN, NO_CONDITION },
{ "ledger_accept", byRef (&doLedgerAccept), Role::ADMIN, NEEDS_CURRENT_LEDGER },
{ "ledger_cleaner", byRef (&doLedgerCleaner), Role::ADMIN, NEEDS_NETWORK_CONNECTION },

View File

@@ -1664,7 +1664,7 @@ public:
auto fee = env.rpc("fee");
if (BEAST_EXPECT(fee.isMember(jss::result) &&
!RPC::contains_error(fee[jss::result])))
BEAST_EXPECT(!RPC::contains_error(fee[jss::result]))))
{
auto const& result = fee[jss::result];
BEAST_EXPECT(result.isMember(jss::ledger_current_index)
@@ -1692,7 +1692,7 @@ public:
fee = env.rpc("fee");
if (BEAST_EXPECT(fee.isMember(jss::result) &&
!RPC::contains_error(fee[jss::result])))
BEAST_EXPECT(!RPC::contains_error(fee[jss::result]))))
{
auto const& result = fee[jss::result];
BEAST_EXPECT(result.isMember(jss::ledger_current_index)