daemon/rpc: updates command and RPC

subcommands "check", "download", and "update".
update is not yet implemented.
This commit is contained in:
moneromooo-monero 2017-02-24 23:16:13 +00:00
parent beee286c7b
commit ea873ceb2c
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
8 changed files with 199 additions and 0 deletions

View file

@ -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