aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/rpc_command_executor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/rpc_command_executor.cpp')
-rw-r--r--src/daemon/rpc_command_executor.cpp53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index b33736839..80109c791 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -34,7 +34,7 @@
#include "daemon/rpc_command_executor.h"
#include "rpc/core_rpc_server_commands_defs.h"
#include "cryptonote_core/cryptonote_core.h"
-#include "cryptonote_basic/hardfork.h"
+#include "cryptonote_core/hardfork.h"
#include <boost/format.hpp>
#include <ctime>
#include <string>
@@ -1494,7 +1494,7 @@ bool t_rpc_command_executor::print_blockchain_dynamic_stats(uint64_t nblocks)
{
return true;
}
- if (!m_rpc_client->rpc_request(fereq, feres, "/get_fee_estimate", fail_message.c_str()))
+ if (!m_rpc_client->json_rpc_request(fereq, feres, "get_fee_estimate", fail_message.c_str()))
{
return true;
}
@@ -1525,7 +1525,7 @@ bool t_rpc_command_executor::print_blockchain_dynamic_stats(uint64_t nblocks)
bhreq.end_height = ires.height - 1;
if (m_is_rpc)
{
- if (!m_rpc_client->rpc_request(bhreq, bhres, "/getblockheadersrange", fail_message.c_str()))
+ if (!m_rpc_client->json_rpc_request(bhreq, bhres, "getblockheadersrange", fail_message.c_str()))
{
return true;
}
@@ -1580,4 +1580,51 @@ bool t_rpc_command_executor::print_blockchain_dynamic_stats(uint64_t nblocks)
return true;
}
+bool t_rpc_command_executor::update(const std::string &command)
+{
+ cryptonote::COMMAND_RPC_UPDATE::request req;
+ cryptonote::COMMAND_RPC_UPDATE::response res;
+ epee::json_rpc::error error_resp;
+
+ std::string fail_message = "Problem fetching info";
+
+ req.command = command;
+ if (m_is_rpc)
+ {
+ if (!m_rpc_client->rpc_request(req, res, "/update", fail_message.c_str()))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if (!m_rpc_server->on_update(req, res) || res.status != CORE_RPC_STATUS_OK)
+ {
+ tools::fail_msg_writer() << fail_message.c_str();
+ return true;
+ }
+ }
+
+ if (!res.update)
+ {
+ tools::msg_writer() << "No update available";
+ return true;
+ }
+
+ tools::msg_writer() << "Update available: v" << res.version << ": " << res.user_uri << ", hash " << res.hash;
+ if (command == "check")
+ return true;
+
+ if (!res.path.empty())
+ tools::msg_writer() << "Update downloaded to: " << res.path;
+ else
+ tools::msg_writer() << "Update download failed: " << res.status;
+ if (command == "download")
+ return true;
+
+ tools::msg_writer() << "'update' not implemented yet";
+
+ return true;
+}
+
}// namespace daemonize