mirror of
https://github.com/monero-project/monero.git
synced 2024-12-28 12:29:26 -05:00
Merge pull request #7384
494f2e1
rpc: fix some error return codes/status (moneromooo-monero)
This commit is contained in:
commit
288e5ec350
@ -605,7 +605,7 @@ namespace cryptonote
|
||||
if (max_blocks == 0)
|
||||
{
|
||||
res.status = CORE_RPC_STATUS_PAYMENT_REQUIRED;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,7 +614,7 @@ namespace cryptonote
|
||||
{
|
||||
res.status = "Failed";
|
||||
add_host_fail(ctx);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
CHECK_PAYMENT_SAME_TS(req, res, bs.size() * COST_PER_BLOCK);
|
||||
@ -650,12 +650,12 @@ namespace cryptonote
|
||||
if (!r)
|
||||
{
|
||||
res.status = "Failed";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (indices.size() != n_txes_to_lookup || res.output_indices.back().indices.size() != (req.no_miner_tx ? 1 : 0))
|
||||
{
|
||||
res.status = "Failed";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
for (size_t i = 0; i < indices.size(); ++i)
|
||||
res.output_indices.back().indices.push_back({std::move(indices[i])});
|
||||
@ -678,7 +678,7 @@ namespace cryptonote
|
||||
if(!m_core.get_alternative_blocks(blks))
|
||||
{
|
||||
res.status = "Failed";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
res.blks_hashes.reserve(blks.size());
|
||||
@ -749,7 +749,7 @@ namespace cryptonote
|
||||
{
|
||||
res.status = "Failed";
|
||||
add_host_fail(ctx);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
CHECK_PAYMENT_SAME_TS(req, res, res.m_block_ids.size() * COST_PER_BLOCK_HASH);
|
||||
@ -1080,7 +1080,7 @@ namespace cryptonote
|
||||
if (!r)
|
||||
{
|
||||
res.status = "Failed";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1456,7 +1456,8 @@ namespace cryptonote
|
||||
res.status = peer_list_res.status;
|
||||
if (!success)
|
||||
{
|
||||
return false;
|
||||
res.status = "Failed to get peer list";
|
||||
return true;
|
||||
}
|
||||
if (res.status != CORE_RPC_STATUS_OK)
|
||||
{
|
||||
@ -1658,7 +1659,7 @@ namespace cryptonote
|
||||
if (m_should_use_bootstrap_daemon)
|
||||
{
|
||||
res.status = "This command is unsupported for bootstrap daemon";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
res.count = m_core.get_current_blockchain_height();
|
||||
@ -1674,7 +1675,7 @@ namespace cryptonote
|
||||
if (m_should_use_bootstrap_daemon)
|
||||
{
|
||||
res = "This command is unsupported for bootstrap daemon";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(req.size() != 1)
|
||||
@ -1984,7 +1985,8 @@ namespace cryptonote
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
if (m_should_use_bootstrap_daemon)
|
||||
{
|
||||
res.status = "This command is unsupported for bootstrap daemon";
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_UNSUPPORTED_BOOTSTRAP;
|
||||
error_resp.message = "This command is unsupported for bootstrap daemon";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2676,7 +2678,7 @@ namespace cryptonote
|
||||
if (!m_core.get_blockchain_storage().flush_txes_from_pool(txids))
|
||||
{
|
||||
res.status = "Failed to remove one or more tx(es)";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (failed)
|
||||
@ -2685,7 +2687,7 @@ namespace cryptonote
|
||||
res.status = "Failed to parse txid";
|
||||
else
|
||||
res.status = "Failed to parse some of the txids";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
@ -2844,7 +2846,7 @@ namespace cryptonote
|
||||
if (req.limit_down != -1)
|
||||
{
|
||||
res.status = CORE_RPC_ERROR_CODE_WRONG_PARAM;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
epee::net_utils::connection_basic::set_rate_down_limit(nodetool::default_limit_down);
|
||||
}
|
||||
@ -2858,7 +2860,7 @@ namespace cryptonote
|
||||
if (req.limit_up != -1)
|
||||
{
|
||||
res.status = CORE_RPC_ERROR_CODE_WRONG_PARAM;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
epee::net_utils::connection_basic::set_rate_up_limit(nodetool::default_limit_up);
|
||||
}
|
||||
@ -2962,17 +2964,17 @@ namespace cryptonote
|
||||
if (!tools::download(path.string(), res.auto_uri))
|
||||
{
|
||||
MERROR("Failed to download " << res.auto_uri);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!tools::sha256sum(path.string(), file_hash))
|
||||
{
|
||||
MERROR("Failed to hash " << path);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (hash != epee::string_tools::pod_to_hex(file_hash))
|
||||
{
|
||||
MERROR("Download from " << res.auto_uri << " does not match the expected hash");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
MINFO("New version downloaded to " << path);
|
||||
}
|
||||
@ -3047,6 +3049,8 @@ namespace cryptonote
|
||||
|
||||
if (failed)
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
error_resp.message = res.status;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3158,7 +3162,7 @@ namespace cryptonote
|
||||
if (!req.binary)
|
||||
{
|
||||
res.status = "Binary only call";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
try
|
||||
{
|
||||
@ -3170,7 +3174,7 @@ namespace cryptonote
|
||||
if (!data)
|
||||
{
|
||||
res.status = "Failed to get output distribution";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
res.distributions.push_back({std::move(*data), amount, "", req.binary, req.compress});
|
||||
@ -3179,7 +3183,7 @@ namespace cryptonote
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
res.status = "Failed to get output distribution";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
@ -3413,7 +3417,8 @@ namespace cryptonote
|
||||
|
||||
if (!m_rpc_payment)
|
||||
{
|
||||
res.status = "Payments not enabled";
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_PAYMENTS_NOT_ENABLED;
|
||||
error_resp.message = "Payments not enabled";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3441,7 +3446,8 @@ namespace cryptonote
|
||||
|
||||
if (!m_rpc_payment)
|
||||
{
|
||||
res.status = "Payments not enabled";
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_PAYMENTS_NOT_ENABLED;
|
||||
error_resp.message = "Payments not enabled";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@
|
||||
#define CORE_RPC_ERROR_CODE_DUPLICATE_PAYMENT -17
|
||||
#define CORE_RPC_ERROR_CODE_STALE_PAYMENT -18
|
||||
#define CORE_RPC_ERROR_CODE_RESTRICTED -19
|
||||
#define CORE_RPC_ERROR_CODE_UNSUPPORTED_BOOTSTRAP -20
|
||||
#define CORE_RPC_ERROR_CODE_PAYMENTS_NOT_ENABLED -21
|
||||
|
||||
static inline const char *get_rpc_server_error_message(int64_t code)
|
||||
{
|
||||
@ -72,6 +74,8 @@ static inline const char *get_rpc_server_error_message(int64_t code)
|
||||
case CORE_RPC_ERROR_CODE_DUPLICATE_PAYMENT: return "Duplicate payment";
|
||||
case CORE_RPC_ERROR_CODE_STALE_PAYMENT: return "Stale payment";
|
||||
case CORE_RPC_ERROR_CODE_RESTRICTED: return "Parameters beyond restricted allowance";
|
||||
case CORE_RPC_ERROR_CODE_UNSUPPORTED_BOOTSTRAP: return "Command is unsupported in bootstrap mode";
|
||||
case CORE_RPC_ERROR_CODE_PAYMENTS_NOT_ENABLED: return "Payments not enabled";
|
||||
default: MERROR("Unknown error: " << code); return "Unknown error";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user