Merge pull request #6035

b90c4bc3 rpc: error out from get_info if the proxied call errors out (moneromooo-monero)
fa16df99 make_test_signature: exit nicely on top level exception (moneromooo-monero)
054b2621 node_rpc_proxy: init some new rpc payment fields in invalidate (moneromooo-monero)
d0faae2a rpc: init a few missing client_info members (moneromooo-monero)
d56a483a rpc: do not propagate exceptions out of a dtor (moneromooo-monero)
3c849188 rpc: always set the update field in update on sucess (moneromooo-monero)
This commit is contained in:
Alexander Blair 2020-02-06 00:26:12 -08:00
commit 25c1bd4714
No known key found for this signature in database
GPG Key ID: C64552D877C32479
4 changed files with 20 additions and 6 deletions

View File

@ -87,11 +87,15 @@ namespace
RPCTracker(const char *rpc, tools::LoggingPerformanceTimer &timer): rpc(rpc), timer(timer) { RPCTracker(const char *rpc, tools::LoggingPerformanceTimer &timer): rpc(rpc), timer(timer) {
} }
~RPCTracker() { ~RPCTracker() {
try
{
boost::unique_lock<boost::mutex> lock(mutex); boost::unique_lock<boost::mutex> lock(mutex);
auto &e = tracker[rpc]; auto &e = tracker[rpc];
++e.count; ++e.count;
e.time += timer.value(); e.time += timer.value();
} }
catch (...) { /* ignore */ }
}
void pay(uint64_t amount) { void pay(uint64_t amount) {
boost::unique_lock<boost::mutex> lock(mutex); boost::unique_lock<boost::mutex> lock(mutex);
auto &e = tracker[rpc]; auto &e = tracker[rpc];
@ -2229,8 +2233,7 @@ namespace cryptonote
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_info_json(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx) bool core_rpc_server::on_get_info_json(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
{ {
on_get_info(req, res, ctx); if (!on_get_info(req, res, ctx) || res.status != CORE_RPC_STATUS_OK)
if (res.status != CORE_RPC_STATUS_OK)
{ {
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = res.status; error_resp.message = res.status;
@ -2624,6 +2627,7 @@ namespace cryptonote
{ {
RPC_TRACKER(update); RPC_TRACKER(update);
res.update = false;
if (m_core.offline()) if (m_core.offline())
{ {
res.status = "Daemon is running offline"; res.status = "Daemon is running offline";

View File

@ -59,6 +59,10 @@
namespace cryptonote namespace cryptonote
{ {
rpc_payment::client_info::client_info(): rpc_payment::client_info::client_info():
previous_seed_height(0),
seed_height(0),
previous_seed_hash(crypto::null_hash),
seed_hash(crypto::null_hash),
cookie(0), cookie(0),
top(crypto::null_hash), top(crypto::null_hash),
previous_top(crypto::null_hash), previous_top(crypto::null_hash),

View File

@ -78,6 +78,10 @@ void NodeRPCProxy::invalidate()
m_rpc_payment_seed_hash = crypto::null_hash; m_rpc_payment_seed_hash = crypto::null_hash;
m_rpc_payment_next_seed_hash = crypto::null_hash; m_rpc_payment_next_seed_hash = crypto::null_hash;
m_height_time = 0; m_height_time = 0;
m_rpc_payment_diff = 0;
m_rpc_payment_credits_per_hash_found = 0;
m_rpc_payment_height = 0;
m_rpc_payment_cookie = 0;
} }
boost::optional<std::string> NodeRPCProxy::get_rpc_version(uint32_t &rpc_version) boost::optional<std::string> NodeRPCProxy::get_rpc_version(uint32_t &rpc_version)

View File

@ -32,6 +32,7 @@
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
TRY_ENTRY();
if (argc > 2) if (argc > 2)
{ {
fprintf(stderr, "usage: %s <secret_key>\n", argv[0]); fprintf(stderr, "usage: %s <secret_key>\n", argv[0]);
@ -57,4 +58,5 @@ int main(int argc, const char **argv)
std::string signature = cryptonote::make_rpc_payment_signature(skey); std::string signature = cryptonote::make_rpc_payment_signature(skey);
printf("%s\n", signature.c_str()); printf("%s\n", signature.c_str());
return 0; return 0;
CATCH_ENTRY_L0("main()", 1);
} }