aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/command_parser_executor.cpp11
-rw-r--r--src/daemon/command_parser_executor.h2
-rw-r--r--src/daemon/command_server.cpp5
-rw-r--r--src/daemon/protocol.h1
-rw-r--r--src/daemon/rpc_command_executor.cpp53
-rw-r--r--src/daemon/rpc_command_executor.h2
6 files changed, 70 insertions, 4 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 8daaac611..4e6e83eb5 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -552,4 +552,15 @@ bool t_command_parser_executor::print_blockchain_dynamic_stats(const std::vector
return m_executor.print_blockchain_dynamic_stats(nblocks);
}
+bool t_command_parser_executor::update(const std::vector<std::string>& args)
+{
+ if(args.size() != 1)
+ {
+ std::cout << "Exactly one parameter is needed: check, download, or update" << std::endl;
+ return false;
+ }
+
+ return m_executor.update(args.front());
+}
+
} // namespace daemonize
diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h
index 37f431974..0a5ca8dd9 100644
--- a/src/daemon/command_parser_executor.h
+++ b/src/daemon/command_parser_executor.h
@@ -130,6 +130,8 @@ public:
bool alt_chain_info(const std::vector<std::string>& args);
bool print_blockchain_dynamic_stats(const std::vector<std::string>& args);
+
+ bool update(const std::vector<std::string>& args);
};
} // namespace daemonize
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index 4a063268f..0081e00dc 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -243,6 +243,11 @@ t_command_server::t_command_server(
, std::bind(&t_command_parser_executor::print_blockchain_dynamic_stats, &m_parser, p::_1)
, "Print information about current blockchain dynamic state"
);
+ m_command_lookup.set_handler(
+ "update"
+ , std::bind(&t_command_parser_executor::update, &m_parser, p::_1)
+ , "subcommands: check (check if an update is available), download (download it is there is), update (not implemented)"
+ );
}
bool t_command_server::process_command_str(const std::string& cmd)
diff --git a/src/daemon/protocol.h b/src/daemon/protocol.h
index a59b6ab1e..fc5edbcaa 100644
--- a/src/daemon/protocol.h
+++ b/src/daemon/protocol.h
@@ -79,7 +79,6 @@ public:
m_protocol.deinit();
m_protocol.set_p2p_endpoint(nullptr);
MGINFO("Cryptonote protocol stopped successfully");
- tools::success_msg_writer() << "Daemon stopped successfully";
} catch (...) {
LOG_ERROR("Failed to stop cryptonote protocol!");
}
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
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index eb95101ce..a015c83ea 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -151,6 +151,8 @@ public:
bool alt_chain_info();
bool print_blockchain_dynamic_stats(uint64_t nblocks);
+
+ bool update(const std::string &command);
};
} // namespace daemonize